From bf7e8bd62b2b36dc25a5c5687d4ef448eb8f06f8 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Tue, 3 Sep 2024 11:09:45 +0000 Subject: [PATCH] Backport #69150 to 24.8: Don't create Object type if use_json_alias_for_old_object_type=1 but allow_experimental_object_type=0 --- src/DataTypes/DataTypeObject.cpp | 4 ++-- .../0_stateless/03230_json_alias_new_old_types.reference | 1 + tests/queries/0_stateless/03230_json_alias_new_old_types.sql | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/DataTypes/DataTypeObject.cpp b/src/DataTypes/DataTypeObject.cpp index be13dc5e727..b06f5639510 100644 --- a/src/DataTypes/DataTypeObject.cpp +++ b/src/DataTypes/DataTypeObject.cpp @@ -517,10 +517,10 @@ static DataTypePtr createJSON(const ASTPtr & arguments) if (!context) context = Context::getGlobalContextInstance(); - if (context->getSettingsRef().use_json_alias_for_old_object_type) + if (context->getSettingsRef().allow_experimental_object_type && context->getSettingsRef().use_json_alias_for_old_object_type) { if (arguments && !arguments->children.empty()) - throw Exception(ErrorCodes::BAD_ARGUMENTS, "Experimental Object type doesn't support any arguments. If you want to use new JSON type, set setting allow_experimental_json_type = 1"); + throw Exception(ErrorCodes::BAD_ARGUMENTS, "Experimental Object type doesn't support any arguments. If you want to use new JSON type, set settings allow_experimental_json_type = 1 and use_json_alias_for_old_object_type = 0"); return std::make_shared("JSON", false); } diff --git a/tests/queries/0_stateless/03230_json_alias_new_old_types.reference b/tests/queries/0_stateless/03230_json_alias_new_old_types.reference index f03e0117618..ad74944e726 100644 --- a/tests/queries/0_stateless/03230_json_alias_new_old_types.reference +++ b/tests/queries/0_stateless/03230_json_alias_new_old_types.reference @@ -1,2 +1,3 @@ {"a":"42"} JSON {"a":42} Object(\'json\') +{"a":"42"} JSON diff --git a/tests/queries/0_stateless/03230_json_alias_new_old_types.sql b/tests/queries/0_stateless/03230_json_alias_new_old_types.sql index 06d4790e0f9..96d4bda171d 100644 --- a/tests/queries/0_stateless/03230_json_alias_new_old_types.sql +++ b/tests/queries/0_stateless/03230_json_alias_new_old_types.sql @@ -6,3 +6,6 @@ set use_json_alias_for_old_object_type=1; select '{"a" : 42}'::JSON as json, toTypeName(json); select '{"a" : 42}'::JSON(max_dynamic_paths=100) as json, toTypeName(json); -- {serverError BAD_ARGUMENTS} +set allow_experimental_object_type = 0; +select materialize('{"a" : 42}')::JSON as json, toTypeName(json); +