Merge pull request #69189 from ClickHouse/backport/24.8/69150

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
This commit is contained in:
robot-clickhouse-ci-2 2024-09-03 17:00:16 +02:00 committed by GitHub
commit bdaeb71faf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 2 deletions

View File

@ -517,10 +517,10 @@ static DataTypePtr createJSON(const ASTPtr & arguments)
if (!context) if (!context)
context = Context::getGlobalContextInstance(); 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()) 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<DataTypeObjectDeprecated>("JSON", false); return std::make_shared<DataTypeObjectDeprecated>("JSON", false);
} }

View File

@ -1,2 +1,3 @@
{"a":"42"} JSON {"a":"42"} JSON
{"a":42} Object(\'json\') {"a":42} Object(\'json\')
{"a":"42"} JSON

View File

@ -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 as json, toTypeName(json);
select '{"a" : 42}'::JSON(max_dynamic_paths=100) as json, toTypeName(json); -- {serverError BAD_ARGUMENTS} 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);