diff --git a/src/Core/Settings.cpp b/src/Core/Settings.cpp index 509738fc8b08..4284793eb44b 100644 --- a/src/Core/Settings.cpp +++ b/src/Core/Settings.cpp @@ -5975,6 +5975,9 @@ This only affects operations performed on the client side, in particular parsing Normally this setting should be set in user profile (users.xml or queries like `ALTER USER`), not through the client (client command line arguments, `SET` query, or `SETTINGS` section of `SELECT` query). Through the client it can be changed to false, but can't be changed to true (because the server won't send the settings if user profile has `apply_settings_from_server = false`). Note that initially (24.12) there was a server setting (`send_settings_to_client`), but latter it got replaced with this client setting, for better usability. +)", 0) \ + DECLARE(Bool, allow_local_data_lakes, false, R"( +Allow using local data lake engines and table functions (IcebergLocal, DeltaLakeLocal, etc.). )", 0) \ \ /* ####################################################### */ \ diff --git a/src/Core/SettingsChangesHistory.cpp b/src/Core/SettingsChangesHistory.cpp index 4707d321b966..d083481bff09 100644 --- a/src/Core/SettingsChangesHistory.cpp +++ b/src/Core/SettingsChangesHistory.cpp @@ -69,6 +69,10 @@ const VersionToSettingsChangesMap & getSettingsChangesHistory() addSettingsChanges(settings_changes_history, "25.4", { }); + addSettingsChanges(settings_changes_history, "25.3.8", + { + {"allow_local_data_lakes", false, false, "New setting to guard local data lake engines and table functions"}, + }); addSettingsChanges(settings_changes_history, "25.3", { /// Release closed. Please use 25.4 diff --git a/src/Storages/ObjectStorage/registerStorageObjectStorage.cpp b/src/Storages/ObjectStorage/registerStorageObjectStorage.cpp index f62b9cae37f0..a1d6537a0428 100644 --- a/src/Storages/ObjectStorage/registerStorageObjectStorage.cpp +++ b/src/Storages/ObjectStorage/registerStorageObjectStorage.cpp @@ -18,6 +18,12 @@ namespace DB namespace ErrorCodes { extern const int BAD_ARGUMENTS; + extern const int SUPPORT_IS_DISABLED; +} + +namespace Setting +{ + extern const SettingsBool allow_local_data_lakes; } namespace @@ -235,6 +241,11 @@ void registerStorageIceberg(StorageFactory & factory) "IcebergLocal", [&](const StorageFactory::Arguments & args) { + if (!args.getLocalContext()->getSettingsRef()[Setting::allow_local_data_lakes]) + throw Exception( + ErrorCodes::SUPPORT_IS_DISABLED, + "IcebergLocal is disabled. Set `allow_local_data_lakes` to enable it"); + auto configuration = std::make_shared(); return createStorageObjectStorage(args, configuration); }, diff --git a/src/TableFunctions/TableFunctionObjectStorage.cpp b/src/TableFunctions/TableFunctionObjectStorage.cpp index 9d95cb73877b..63bab552843d 100644 --- a/src/TableFunctions/TableFunctionObjectStorage.cpp +++ b/src/TableFunctions/TableFunctionObjectStorage.cpp @@ -31,6 +31,7 @@ namespace DB namespace Setting { + extern const SettingsBool allow_local_data_lakes; extern const SettingsUInt64 allow_experimental_parallel_reading_from_replicas; extern const SettingsBool parallel_replicas_for_cluster_engines; extern const SettingsString cluster_for_parallel_replicas; @@ -40,6 +41,7 @@ namespace Setting namespace ErrorCodes { extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH; + extern const int SUPPORT_IS_DISABLED; } template @@ -79,6 +81,15 @@ std::vector TableFunctionObjectStorage::skipA template void TableFunctionObjectStorage::parseArguments(const ASTPtr & ast_function, ContextPtr context) { + if constexpr (std::is_same_v) + { + if (!context->getSettingsRef()[Setting::allow_local_data_lakes]) + throw Exception( + ErrorCodes::SUPPORT_IS_DISABLED, + "Table function '{}' is disabled. Set `allow_local_data_lakes` to enable it", + getName()); + } + /// Clone ast function, because we can modify its arguments like removing headers. auto ast_copy = ast_function->clone(); ASTs & args_func = ast_copy->children; @@ -109,6 +120,15 @@ template ColumnsDescription TableFunctionObjectStorage< Definition, Configuration>::getActualTableStructure(ContextPtr context, bool is_insert_query) const { + if constexpr (std::is_same_v) + { + if (!context->getSettingsRef()[Setting::allow_local_data_lakes]) + throw Exception( + ErrorCodes::SUPPORT_IS_DISABLED, + "Table function '{}' is disabled. Set `allow_local_data_lakes` to enable it", + getName()); + } + if (configuration->structure == "auto") { context->checkAccess(getSourceAccessType()); @@ -129,6 +149,15 @@ StoragePtr TableFunctionObjectStorage::executeImpl( ColumnsDescription cached_columns, bool is_insert_query) const { + if constexpr (std::is_same_v) + { + if (!context->getSettingsRef()[Setting::allow_local_data_lakes]) + throw Exception( + ErrorCodes::SUPPORT_IS_DISABLED, + "Table function '{}' is disabled. Set `allow_local_data_lakes` to enable it", + getName()); + } + chassert(configuration); ColumnsDescription columns; @@ -287,6 +316,10 @@ template class TableFunctionObjectStorage; +#if USE_AVRO +template class TableFunctionObjectStorage; +#endif + #if USE_AVRO && USE_AWS_S3 template class TableFunctionObjectStorage; #endif diff --git a/tests/integration/test_storage_iceberg/configs/users.d/users.xml b/tests/integration/test_storage_iceberg/configs/users.d/users.xml index 4b6ba057ecb1..3d166f3c17af 100644 --- a/tests/integration/test_storage_iceberg/configs/users.d/users.xml +++ b/tests/integration/test_storage_iceberg/configs/users.d/users.xml @@ -4,6 +4,12 @@ default 1 + 1 + + + 1 + +