Fix enumerating dynamic subcolumns

This commit is contained in:
avogar 2024-08-19 22:00:35 +00:00
parent 09d4964de5
commit bc9cac605a
6 changed files with 28 additions and 2 deletions

View File

@ -150,6 +150,7 @@ std::unique_ptr<IDataType::SubstreamData> IDataType::getSubcolumnData(
ISerialization::EnumerateStreamsSettings settings;
settings.position_independent_encoding = false;
settings.enumerate_dynamic_streams = false;
data.serialization->enumerateStreams(settings, callback_with_data, data);
if (!res && data.type->hasDynamicSubcolumnsData())

View File

@ -241,6 +241,7 @@ public:
{
SubstreamPath path;
bool position_independent_encoding = true;
bool enumerate_dynamic_streams = true;
};
virtual void enumerateStreams(

View File

@ -64,7 +64,7 @@ void SerializationDynamic::enumerateStreams(
const auto * deserialize_state = data.deserialize_state ? checkAndGetState<DeserializeBinaryBulkStateDynamic>(data.deserialize_state) : nullptr;
/// If column is nullptr and we don't have deserialize state yet, nothing to enumerate as we don't have any variants.
if (!column_dynamic && !deserialize_state)
if (!settings.enumerate_dynamic_streams || (!column_dynamic && !deserialize_state))
return;
const auto & variant_type = column_dynamic ? column_dynamic->getVariantInfo().variant_type : checkAndGetState<DeserializeBinaryBulkStateDynamicStructure>(deserialize_state->structure_state)->variant_type;

View File

@ -130,7 +130,7 @@ void SerializationObject::enumerateStreams(EnumerateStreamsSettings & settings,
}
/// If column or deserialization state was provided, iterate over dynamic paths,
if (column_object || structure_state)
if (settings.enumerate_dynamic_streams && (column_object || structure_state))
{
/// Enumerate dynamic paths in sorted order for consistency.
const auto * dynamic_paths = column_object ? &column_object->getDynamicPaths() : nullptr;

View File

@ -0,0 +1,15 @@
\N
\N
\N
\N
\N
str_0
str_1
str_2
str_3
str_4
\N
\N
\N
\N
\N

View File

@ -0,0 +1,9 @@
set allow_experimental_json_type=1;
drop table if exists test;
create table test (json JSON) engine=Memory;
insert into test select toJSONString(map('a', 'str_' || number)) from numbers(5);
select json.a.String from test;
select json.a.:String from test;
select json.a.UInt64 from test;
drop table test;