diff --git a/src/DataTypes/Serializations/SerializationDynamic.cpp b/src/DataTypes/Serializations/SerializationDynamic.cpp index 91c8797d43f..1b999819f79 100644 --- a/src/DataTypes/Serializations/SerializationDynamic.cpp +++ b/src/DataTypes/Serializations/SerializationDynamic.cpp @@ -762,8 +762,12 @@ void SerializationDynamic::serializeTextJSON(const IColumn & column, size_t row_ void SerializationDynamic::serializeTextJSONPretty(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings & settings, size_t indent) const { - const auto & dynamic_column = assert_cast(column); - dynamic_column.getVariantInfo().variant_type->getDefaultSerialization()->serializeTextJSONPretty(dynamic_column.getVariantColumn(), row_num, ostr, settings, indent); + auto nested_serialize = [&settings, indent](const ISerialization & serialization, const IColumn & col, size_t row, WriteBuffer & buf) + { + serialization.serializeTextJSONPretty(col, row, buf, settings, indent); + }; + + serializeTextImpl(column, row_num, ostr, settings, nested_serialize); } void SerializationDynamic::deserializeTextJSON(IColumn & column, ReadBuffer & istr, const FormatSettings & settings) const diff --git a/tests/queries/0_stateless/03273_dynamic_pretty_json_serialization.reference b/tests/queries/0_stateless/03273_dynamic_pretty_json_serialization.reference new file mode 100644 index 00000000000..8d89910f707 --- /dev/null +++ b/tests/queries/0_stateless/03273_dynamic_pretty_json_serialization.reference @@ -0,0 +1,6 @@ +{ + "d": "Hello" +} +{ + "d": "Hello" +} diff --git a/tests/queries/0_stateless/03273_dynamic_pretty_json_serialization.sql b/tests/queries/0_stateless/03273_dynamic_pretty_json_serialization.sql new file mode 100644 index 00000000000..0c5ff73d8d4 --- /dev/null +++ b/tests/queries/0_stateless/03273_dynamic_pretty_json_serialization.sql @@ -0,0 +1,6 @@ +set allow_experimental_dynamic_type = 1; + +select 'Hello'::Dynamic(max_types=1) as d format PrettyJSONEachRow; +select 'Hello'::Dynamic(max_types=0) as d format PrettyJSONEachRow; + +