Skip to content

Commit 2e55e90

Browse files
committed
Fix object_storage_cluster setting and system.iceberg_history table
1 parent baffd1f commit 2e55e90

File tree

5 files changed

+26
-13
lines changed

5 files changed

+26
-13
lines changed

src/Databases/DataLake/DatabaseDataLake.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ DatabaseTablesIteratorPtr DatabaseDataLake::getLightweightTablesIterator(
480480
const FilterByNameFunction & filter_by_table_name,
481481
bool skip_not_loaded) const
482482
{
483-
Tables tables;
483+
Tables tables;
484484
auto catalog = getCatalog();
485485
const auto iceberg_tables = catalog->getTables();
486486

src/Storages/ObjectStorage/StorageObjectStorageCluster.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,4 +530,18 @@ StorageMetadataPtr StorageObjectStorageCluster::getInMemoryMetadataPtr() const
530530
return IStorageCluster::getInMemoryMetadataPtr();
531531
}
532532

533+
IDataLakeMetadata * StorageObjectStorageCluster::getExternalMetadata(ContextPtr query_context)
534+
{
535+
if (pure_storage)
536+
return pure_storage->getExternalMetadata(query_context);
537+
538+
configuration->update(
539+
object_storage,
540+
query_context,
541+
/* if_not_updated_before */false,
542+
/* check_consistent_with_previous_metadata */false);
543+
544+
return configuration->getExternalMetadata();
545+
}
546+
533547
}

src/Storages/ObjectStorage/StorageObjectStorageCluster.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ class StorageObjectStorageCluster : public IStorageCluster
5050

5151
void addInferredEngineArgsToCreateQuery(ASTs & args, const ContextPtr & context) const override;
5252

53+
IDataLakeMetadata * getExternalMetadata(ContextPtr query_context);
54+
5355
bool updateExternalDynamicMetadataIfExists(ContextPtr context) override;
5456

5557
StorageMetadataPtr getInMemoryMetadataPtr() const override;

src/Storages/ObjectStorage/registerStorageObjectStorage.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ namespace ErrorCodes
2222
extern const int BAD_ARGUMENTS;
2323
}
2424

25-
namespace StorageObjectStorageSetting
26-
{
27-
extern const StorageObjectStorageSettingsString object_storage_cluster;
28-
}
29-
3025
namespace
3126
{
3227

@@ -41,12 +36,14 @@ createStorageObjectStorage(const StorageFactory::Arguments & args, StorageObject
4136
throw Exception(ErrorCodes::BAD_ARGUMENTS, "External data source must have arguments");
4237

4338
const auto context = args.getLocalContext();
44-
auto storage_settings = std::make_shared<StorageObjectStorageSettings>();
39+
40+
std::string cluster_name = "";
4541

4642
if (args.storage_def->settings)
47-
storage_settings->loadFromQuery(*args.storage_def->settings);
48-
49-
auto cluster_name = (*storage_settings)[StorageObjectStorageSetting::object_storage_cluster].value;
43+
{
44+
if (const auto * value = args.storage_def->settings->changes.tryGet("object_storage_cluster"))
45+
cluster_name = value->safeGet<std::string>();
46+
}
5047

5148
configuration->initialize(args.engine_args, context, false);
5249

src/Storages/System/StorageSystemIcebergHistory.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <Processors/QueryPlan/QueryPlan.h>
1616
#include <Processors/QueryPlan/ReadFromSystemNumbersStep.h>
1717
#include <Storages/SelectQueryInfo.h>
18-
#include <Storages/ObjectStorage/StorageObjectStorage.h>
18+
#include <Storages/ObjectStorage/StorageObjectStorageCluster.h>
1919
#include <Access/ContextAccess.h>
2020
#include <Storages/ObjectStorage/DataLakes/DataLakeConfiguration.h>
2121
#include <Storages/ObjectStorage/DataLakes/Iceberg/IcebergMetadata.h>
@@ -51,7 +51,7 @@ void StorageSystemIcebergHistory::fillData([[maybe_unused]] MutableColumns & res
5151
#if USE_AVRO
5252
const auto access = context->getAccess();
5353

54-
auto add_history_record = [&](const DatabaseTablesIteratorPtr & it, StorageObjectStorage * object_storage)
54+
auto add_history_record = [&](const DatabaseTablesIteratorPtr & it, StorageObjectStorageCluster * object_storage)
5555
{
5656
if (!access->isGranted(AccessType::SHOW_TABLES, it->databaseName(), it->name()))
5757
return;
@@ -100,7 +100,7 @@ void StorageSystemIcebergHistory::fillData([[maybe_unused]] MutableColumns & res
100100
// Table was dropped while acquiring the lock, skipping table
101101
continue;
102102

103-
if (auto * object_storage_table = dynamic_cast<StorageObjectStorage *>(storage.get()))
103+
if (auto * object_storage_table = dynamic_cast<StorageObjectStorageCluster *>(storage.get()))
104104
{
105105
add_history_record(iterator, object_storage_table);
106106
}

0 commit comments

Comments
 (0)