Merge pull request #71747 from ClickHouse/backport/24.8/71369

Backport #71369 to 24.8: Check suspicious and experimental types in JSON type hints
This commit is contained in:
robot-clickhouse-ci-1 2024-11-11 17:14:31 +01:00 committed by GitHub
commit aa7b7097f3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 21 additions and 0 deletions

View File

@ -222,6 +222,15 @@ MutableColumnPtr DataTypeObject::createColumn() const
return ColumnObject::create(std::move(typed_path_columns), max_dynamic_paths, max_dynamic_types); return ColumnObject::create(std::move(typed_path_columns), max_dynamic_paths, max_dynamic_types);
} }
void DataTypeObject::forEachChild(const ChildCallback & callback) const
{
for (const auto & [path, type] : typed_paths)
{
callback(*type);
type->forEachChild(callback);
}
}
namespace namespace
{ {

View File

@ -50,6 +50,8 @@ public:
bool equals(const IDataType & rhs) const override; bool equals(const IDataType & rhs) const override;
void forEachChild(const ChildCallback &) const override;
bool hasDynamicSubcolumnsData() const override { return true; } bool hasDynamicSubcolumnsData() const override { return true; }
std::unique_ptr<SubstreamData> getDynamicSubcolumnData(std::string_view subcolumn_name, const SubstreamData & data, bool throw_if_null) const override; std::unique_ptr<SubstreamData> getDynamicSubcolumnData(std::string_view subcolumn_name, const SubstreamData & data, bool throw_if_null) const override;

View File

@ -1,6 +1,7 @@
-- Tags: no-fasttest -- Tags: no-fasttest
set allow_experimental_json_type = 1; set allow_experimental_json_type = 1;
set allow_experimental_dynamic_type = 1;
drop table if exists test; drop table if exists test;
create table test (json JSON(a Dynamic)) engine=MergeTree order by tuple() settings min_rows_for_wide_part=1, min_bytes_for_wide_part=1; create table test (json JSON(a Dynamic)) engine=MergeTree order by tuple() settings min_rows_for_wide_part=1, min_bytes_for_wide_part=1;
insert into test select '{"a" : 42}'; insert into test select '{"a" : 42}';

View File

@ -0,0 +1,9 @@
set allow_experimental_json_type=1;
set allow_experimental_variant_type=0;
set allow_experimental_object_type=0;
select '{}'::JSON(a LowCardinality(Int128)); -- {serverError SUSPICIOUS_TYPE_FOR_LOW_CARDINALITY}
select '{}'::JSON(a FixedString(100000)); -- {serverError ILLEGAL_COLUMN}
select '{}'::JSON(a Variant(Int32)); -- {serverError ILLEGAL_COLUMN}
select '{}'::JSON(a Object('json')); -- {serverError ILLEGAL_COLUMN}