Skip to content

Commit 253f4eb

Browse files
authored
Merge pull request ClickHouse#79407 from ClickHouse/support-settings-for-delta-table-in-catalog
Allow to specify storage settings for DatabaseCatalog
2 parents f14141a + c94d94d commit 253f4eb

File tree

6 files changed

+65
-34
lines changed

6 files changed

+65
-34
lines changed

ci/jobs/scripts/check_style/check-settings-style

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ ALL_DECLARATION_FILES="
3737
$ROOT_PATH/src/Storages/MySQL/MySQLSettings.cpp
3838
$ROOT_PATH/src/Storages/NATS/NATSSettings.cpp
3939
$ROOT_PATH/src/Storages/ObjectStorageQueue/ObjectStorageQueueSettings.cpp
40-
$ROOT_PATH/src/Storages/ObjectStorage/StorageObjectStorageSettings.cpp
40+
$ROOT_PATH/src/Storages/ObjectStorage/StorageObjectStorageSettings.h
4141
$ROOT_PATH/src/Storages/PostgreSQL/MaterializedPostgreSQLSettings.cpp
4242
$ROOT_PATH/src/Storages/RabbitMQ/RabbitMQSettings.cpp
4343
$ROOT_PATH/src/Storages/RocksDB/RocksDBSettings.cpp

src/Databases/DataLake/DatabaseDataLake.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,8 @@ StoragePtr DatabaseDataLake::tryGetTableImpl(const String & name, ContextPtr con
380380
const auto configuration = getConfiguration(storage_type);
381381

382382
auto storage_settings = std::make_shared<StorageObjectStorageSettings>();
383+
storage_settings->loadFromSettingsChanges(settings.allChanged());
384+
383385
if (auto table_specific_properties = table_metadata.getDataLakeSpecificProperties();
384386
table_specific_properties.has_value())
385387
{

src/Databases/DataLake/DatabaseDataLakeSettings.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <Parsers/ASTFunction.h>
55
#include <Parsers/ASTSetQuery.h>
66
#include <Databases/DataLake/DatabaseDataLakeSettings.h>
7+
#include <Storages/ObjectStorage/StorageObjectStorageSettings.h>
78
#include <Common/Exception.h>
89

910
namespace DB
@@ -28,7 +29,8 @@ namespace ErrorCodes
2829
DECLARE(String, storage_endpoint, "", "Object storage endpoint", 0) \
2930

3031
#define LIST_OF_DATABASE_ICEBERG_SETTINGS(M, ALIAS) \
31-
DATABASE_ICEBERG_RELATED_SETTINGS(M, ALIAS)
32+
DATABASE_ICEBERG_RELATED_SETTINGS(M, ALIAS) \
33+
LIST_OF_STORAGE_OBJECT_STORAGE_SETTINGS(M, ALIAS) \
3234

3335
DECLARE_SETTINGS_TRAITS(DatabaseDataLakeSettingsTraits, LIST_OF_DATABASE_ICEBERG_SETTINGS)
3436
IMPLEMENT_SETTINGS_TRAITS(DatabaseDataLakeSettingsTraits, LIST_OF_DATABASE_ICEBERG_SETTINGS)
@@ -88,4 +90,12 @@ void DatabaseDataLakeSettings::loadFromQuery(const ASTStorage & storage_def)
8890
}
8991
}
9092

93+
SettingsChanges DatabaseDataLakeSettings::allChanged() const
94+
{
95+
SettingsChanges changes;
96+
for (const auto & setting : impl->allChanged())
97+
changes.emplace_back(setting.getName(), setting.getValue());
98+
return changes;
99+
}
100+
91101
}

src/Databases/DataLake/DatabaseDataLakeSettings.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <Core/BaseSettingsFwdMacros.h>
44
#include <Core/FormatFactorySettings.h>
5+
#include <Storages/ObjectStorage/StorageObjectStorageSettings.h>
56
#include <Core/SettingsEnums.h>
67
#include <Core/SettingsFields.h>
78

@@ -19,7 +20,11 @@ class SettingsChanges;
1920
M(CLASS_NAME, Bool) \
2021
M(CLASS_NAME, DatabaseDataLakeCatalogType) \
2122

22-
DATABASE_ICEBERG_SETTINGS_SUPPORTED_TYPES(DatabaseDataLakeSettings, DECLARE_SETTING_TRAIT)
23+
#define LIST_OF_DATABASE_ICEBERG_SETTINGS_SUPPORTED_TYPES(CLASS_NAME, M) \
24+
DATABASE_ICEBERG_SETTINGS_SUPPORTED_TYPES(CLASS_NAME, M) \
25+
STORAGE_OBJECT_STORAGE_SETTINGS_SUPPORTED_TYPES(CLASS_NAME, M)
26+
27+
LIST_OF_DATABASE_ICEBERG_SETTINGS_SUPPORTED_TYPES(DatabaseDataLakeSettings, DECLARE_SETTING_TRAIT)
2328

2429
struct DatabaseDataLakeSettings
2530
{
@@ -34,6 +39,8 @@ struct DatabaseDataLakeSettings
3439

3540
void applyChanges(const SettingsChanges & changes);
3641

42+
SettingsChanges allChanged() const;
43+
3744
private:
3845
std::unique_ptr<DatabaseDataLakeSettingsImpl> impl;
3946
};

src/Storages/ObjectStorage/StorageObjectStorageSettings.cpp

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,6 @@
1111
namespace DB
1212
{
1313

14-
// clang-format off
15-
16-
#define STORAGE_OBJECT_STORAGE_RELATED_SETTINGS(DECLARE, ALIAS) \
17-
DECLARE(Bool, allow_dynamic_metadata_for_data_lakes, false, R"(
18-
If enabled, indicates that metadata is taken from iceberg specification that is pulled from cloud before each query.
19-
)", 0) \
20-
DECLARE(Bool, allow_experimental_delta_kernel_rs, false, R"(
21-
If enabled, the engine would use delta-kernel-rs for DeltaLake metadata parsing
22-
)", 0) \
23-
DECLARE(Bool, delta_lake_read_schema_same_as_table_schema, false, R"(
24-
Whether delta-lake read schema is the same as table schema.
25-
)", 0) \
26-
DECLARE(String, iceberg_metadata_file_path, "", R"(
27-
Explicit path to desired Iceberg metadata file, should be relative to path in object storage. Make sense for table function use case only.
28-
)", 0) \
29-
DECLARE(String, iceberg_metadata_table_uuid, "", R"(
30-
Explicit table UUID to read metadata for. Ignored if iceberg_metadata_file_path is set.
31-
)", 0) \
32-
DECLARE(Bool, iceberg_recent_metadata_file_by_last_updated_ms_field, false, R"(
33-
If enabled, the engine would use the metadata file with the most recent last_updated_ms json field. Does not make sense to use with iceberg_metadata_file_path.
34-
)", 0) \
35-
DECLARE(Bool, iceberg_use_version_hint, false, R"(
36-
Get latest metadata path from version-hint.text file.
37-
)", 0) \
38-
39-
// clang-format on
40-
41-
#define LIST_OF_STORAGE_OBJECT_STORAGE_SETTINGS(M, ALIAS) \
42-
STORAGE_OBJECT_STORAGE_RELATED_SETTINGS(M, ALIAS) \
43-
LIST_OF_ALL_FORMAT_SETTINGS(M, ALIAS)
44-
4514
DECLARE_SETTINGS_TRAITS(StorageObjectStorageSettingsTraits, LIST_OF_STORAGE_OBJECT_STORAGE_SETTINGS)
4615
IMPLEMENT_SETTINGS_TRAITS(StorageObjectStorageSettingsTraits, LIST_OF_STORAGE_OBJECT_STORAGE_SETTINGS)
4716

@@ -93,4 +62,14 @@ bool StorageObjectStorageSettings::hasBuiltin(std::string_view name)
9362
{
9463
return StorageObjectStorageSettingsImpl::hasBuiltin(name);
9564
}
65+
66+
void StorageObjectStorageSettings::loadFromSettingsChanges(const SettingsChanges & changes)
67+
{
68+
for (const auto & [name, value] : changes)
69+
{
70+
if (impl->has(name))
71+
impl->set(name, value);
72+
}
73+
}
74+
9675
}

src/Storages/ObjectStorage/StorageObjectStorageSettings.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,33 @@ class SettingsChanges;
4444
M(CLASS_NAME, UInt64Auto) \
4545
M(CLASS_NAME, URI)
4646

47+
// clang-format off
48+
49+
#define STORAGE_OBJECT_STORAGE_RELATED_SETTINGS(DECLARE, ALIAS) \
50+
DECLARE(Bool, allow_dynamic_metadata_for_data_lakes, false, R"(
51+
If enabled, indicates that metadata is taken from iceberg specification that is pulled from cloud before each query.
52+
)", 0) \
53+
DECLARE(Bool, allow_experimental_delta_kernel_rs, false, R"(
54+
If enabled, the engine would use delta-kernel-rs for DeltaLake metadata parsing
55+
)", 0) \
56+
DECLARE(Bool, delta_lake_read_schema_same_as_table_schema, false, R"(
57+
Whether delta-lake read schema is the same as table schema.
58+
)", 0) \
59+
DECLARE(String, iceberg_metadata_file_path, "", R"(
60+
Explicit path to desired Iceberg metadata file, should be relative to path in object storage. Make sense for table function use case only.
61+
)", 0) \
62+
DECLARE(String, iceberg_metadata_table_uuid, "", R"(
63+
Explicit table UUID to read metadata for. Ignored if iceberg_metadata_file_path is set.
64+
)", 0) \
65+
DECLARE(Bool, iceberg_recent_metadata_file_by_last_updated_ms_field, false, R"(
66+
If enabled, the engine would use the metadata file with the most recent last_updated_ms json field. Does not make sense to use with iceberg_metadata_file_path.
67+
)", 0) \
68+
DECLARE(Bool, iceberg_use_version_hint, false, R"(
69+
Get latest metadata path from version-hint.text file.
70+
)", 0) \
71+
72+
// clang-format on
73+
4774
STORAGE_OBJECT_STORAGE_SETTINGS_SUPPORTED_TYPES(StorageObjectStorageSettings, DECLARE_SETTING_TRAIT)
4875

4976
struct StorageObjectStorageSettings
@@ -57,6 +84,8 @@ struct StorageObjectStorageSettings
5784

5885
void loadFromQuery(ASTSetQuery & settings_ast);
5986

87+
void loadFromSettingsChanges(const SettingsChanges & changes);
88+
6089
Field get(const std::string & name);
6190

6291
static bool hasBuiltin(std::string_view name);
@@ -67,4 +96,8 @@ struct StorageObjectStorageSettings
6796

6897
using StorageObjectStorageSettingsPtr = std::shared_ptr<StorageObjectStorageSettings>;
6998

99+
#define LIST_OF_STORAGE_OBJECT_STORAGE_SETTINGS(M, ALIAS) \
100+
STORAGE_OBJECT_STORAGE_RELATED_SETTINGS(M, ALIAS) \
101+
LIST_OF_ALL_FORMAT_SETTINGS(M, ALIAS)
102+
70103
}

0 commit comments

Comments
 (0)