mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-19 16:20:50 +00:00
Merge pull request #68955 from Avogar/fix-json-type-parsing-null-as-default
Fix JSON type parsing with nulls as defaults
This commit is contained in:
commit
b1e7c067c9
@ -1179,6 +1179,12 @@ public:
|
||||
const FormatSettings & format_settings,
|
||||
String & error) const override
|
||||
{
|
||||
if (element.isNull() && format_settings.null_as_default)
|
||||
{
|
||||
column.insertDefault();
|
||||
return true;
|
||||
}
|
||||
|
||||
auto & tuple = assert_cast<ColumnTuple &>(column);
|
||||
size_t old_size = column.size();
|
||||
bool were_valid_elements = false;
|
||||
@ -1298,6 +1304,12 @@ public:
|
||||
const FormatSettings & format_settings,
|
||||
String & error) const override
|
||||
{
|
||||
if (element.isNull() && format_settings.null_as_default)
|
||||
{
|
||||
column.insertDefault();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!element.isObject())
|
||||
{
|
||||
error = fmt::format("cannot read Map value from JSON element: {}", jsonElementToString<JSONParser>(element, format_settings));
|
||||
@ -1362,6 +1374,14 @@ public:
|
||||
String & error) const override
|
||||
{
|
||||
auto & column_variant = assert_cast<ColumnVariant &>(column);
|
||||
|
||||
/// Check if element is NULL.
|
||||
if (element.isNull())
|
||||
{
|
||||
column_variant.insertDefault();
|
||||
return true;
|
||||
}
|
||||
|
||||
for (size_t i : order)
|
||||
{
|
||||
auto & variant = column_variant.getVariantByGlobalDiscriminator(i);
|
||||
|
@ -0,0 +1 @@
|
||||
{"a":[["1",{}],[null,{}]]} [(1,'{}'),(NULL,'{}')] Array(Tuple(Nullable(Int64), JSON(max_dynamic_types=16, max_dynamic_paths=256)))
|
@ -0,0 +1,4 @@
|
||||
set allow_experimental_json_type=1;
|
||||
|
||||
select materialize('{"a" : [[1, {}], null]}')::JSON as json, getSubcolumn(json, 'a'), dynamicType(getSubcolumn(json, 'a'));
|
||||
|
Loading…
Reference in New Issue
Block a user