Handle dynamic columns in typed paths

This commit is contained in:
avogar 2024-08-01 11:24:50 +00:00
parent bcd53dcd20
commit aaa7750bf9
3 changed files with 31 additions and 0 deletions

View File

@ -1211,6 +1211,16 @@ void ColumnObject::takeDynamicStructureFromSourceColumns(const DB::Columns & sou
}
column->takeDynamicStructureFromSourceColumns(dynamic_path_source_columns);
}
/// Typed paths also can contain types with dynamic structure.
for (auto & [path, column] : typed_paths)
{
Columns typed_path_source_columns;
typed_path_source_columns.reserve(source_columns.size());
for (const auto & source_column : source_columns)
typed_path_source_columns.push_back(assert_cast<const ColumnObject &>(*source_column).typed_paths.at(path));
column->takeDynamicStructureFromSourceColumns(typed_path_source_columns);
}
}
size_t ColumnObject::findPathLowerBoundInSharedData(StringRef path, const ColumnString & shared_data_paths, size_t start, size_t end)

View File

@ -0,0 +1,4 @@
{"a":"42"}
{"a":["1","2","3"]}
{"a":"42"}
{"a":["1","2","3"]}

View File

@ -0,0 +1,17 @@
-- Tags: no-fasttest
set allow_experimental_json_type = 1;
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;
insert into test select '{"a" : 42}';
insert into test select '{"a" : [1, 2, 3]}';
optimize table test;
select * from test order by toString(json);
drop table test;
create table test (json JSON(a Dynamic)) engine=MergeTree order by tuple() settings min_rows_for_wide_part=10000000, min_bytes_for_wide_part=10000000;
insert into test select '{"a" : 42}';
insert into test select '{"a" : [1, 2, 3]}';
optimize table test;
select * from test order by toString(json);
drop table test;