From b59edcce40bb91f21fc5ac905834f955c2688a89 Mon Sep 17 00:00:00 2001 From: Kirill Nikiforov Date: Thu, 19 Sep 2024 18:06:42 +0400 Subject: [PATCH] fix after master merge --- src/Core/Settings.cpp | 1 + src/Dictionaries/MongoDBPocoLegacyDictionarySource.cpp | 1 + src/Storages/StorageMongoDB.cpp | 10 ++++++++-- src/Storages/StorageMongoDB.h | 2 ++ src/Storages/StorageMongoDBPocoLegacy.cpp | 1 + 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Core/Settings.cpp b/src/Core/Settings.cpp index 4518d78657c..72a46a5f9d8 100644 --- a/src/Core/Settings.cpp +++ b/src/Core/Settings.cpp @@ -918,6 +918,7 @@ namespace ErrorCodes M(Bool, restore_replace_external_engines_to_null, false, "Replace all the external table engines to Null on restore. Useful for testing purposes", 0) \ M(Bool, restore_replace_external_table_functions_to_null, false, "Replace all table functions to Null on restore. Useful for testing purposes", 0) \ M(Bool, create_if_not_exists, false, "Enable IF NOT EXISTS for CREATE statements by default", 0) \ + M(Bool, mongodb_throw_on_unsupported_query, true, "If enabled, MongoDB tables will return an error when a MongoDB query cannot be built. Otherwise, ClickHouse reads the full table and processes it locally. This option does not apply to the legacy implementation or when 'allow_experimental_analyzer=0'.", 0) \ \ \ /* ###################################### */ \ diff --git a/src/Dictionaries/MongoDBPocoLegacyDictionarySource.cpp b/src/Dictionaries/MongoDBPocoLegacyDictionarySource.cpp index ef7e8f05f90..4495215d826 100644 --- a/src/Dictionaries/MongoDBPocoLegacyDictionarySource.cpp +++ b/src/Dictionaries/MongoDBPocoLegacyDictionarySource.cpp @@ -2,6 +2,7 @@ #include "DictionarySourceFactory.h" #if USE_MONGODB +#include #include "MongoDBPocoLegacyDictionarySource.h" #include "DictionaryStructure.h" #include "registerDictionaries.h" diff --git a/src/Storages/StorageMongoDB.cpp b/src/Storages/StorageMongoDB.cpp index 437beee9458..64971d0c8cd 100644 --- a/src/Storages/StorageMongoDB.cpp +++ b/src/Storages/StorageMongoDB.cpp @@ -42,6 +42,12 @@ namespace ErrorCodes extern const int NOT_IMPLEMENTED; } +namespace Setting +{ + extern const SettingsBool allow_experimental_analyzer; + extern const SettingsBool mongodb_throw_on_unsupported_query; +} + using BSONCXXHelper::fieldAsBSONValue; using BSONCXXHelper::fieldAsOID; @@ -279,9 +285,9 @@ bsoncxx::document::value StorageMongoDB::buildMongoDBQuery(const ContextPtr & co LOG_DEBUG(log, "MongoDB projection has built: '{}'", bsoncxx::to_json(projection)); options.projection(projection.extract()); - bool throw_on_error = context->getSettingsRef().mongodb_throw_on_unsupported_query; + bool throw_on_error = context->getSettingsRef()[Setting::mongodb_throw_on_unsupported_query]; - if (!context->getSettingsRef().allow_experimental_analyzer) + if (!context->getSettingsRef()[Setting::allow_experimental_analyzer]) { if (throw_on_error) throw Exception(ErrorCodes::NOT_IMPLEMENTED, "MongoDB storage does not support 'allow_experimental_analyzer = 0' setting"); diff --git a/src/Storages/StorageMongoDB.h b/src/Storages/StorageMongoDB.h index 644b0d627dd..15052c67e76 100644 --- a/src/Storages/StorageMongoDB.h +++ b/src/Storages/StorageMongoDB.h @@ -3,6 +3,8 @@ #include "config.h" #if USE_MONGODB +#include + #include #include #include diff --git a/src/Storages/StorageMongoDBPocoLegacy.cpp b/src/Storages/StorageMongoDBPocoLegacy.cpp index 7d7b84f10bf..04f73cb0510 100644 --- a/src/Storages/StorageMongoDBPocoLegacy.cpp +++ b/src/Storages/StorageMongoDBPocoLegacy.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include