Skip to content

Use Array(Dynamic) instead of unnamed tuple for arrays of values with different data types in JSON subcolumn types inference #74937

@Avogar

Description

@Avogar

Company or project name

ClickHouse

Use case

Right now during new JSON type parsing an array of different data types is inferred as an unnamed tuple:

:) select JSONAllPathsWithTypes('{"a" : ["Hello", 1, [1, 2, 3]]}'::JSON)

SELECT JSONAllPathsWithTypes(CAST('{"a" : ["Hello", 1, [1, 2, 3]]}', 'JSON'))

Query id: 0af75119-32bc-4224-b07e-c67e3de422fe

   ┌─JSONAllPathsWithTypes(CAST('{"a" : ["Hello", 1, [1, 2, 3]]}', 'JSON'))───┐
1. │ {'a':'Tuple(Nullable(String), Nullable(Int64), Array(Nullable(Int64)))'} │
   └──────────────────────────────────────────────────────────────────────────┘

But working with unnamed tuples is really difficult, especially when you need to iterate over its fields. It would be better to infer type Array(Dynamic) in this case.

Describe the solution you'd like

:) select JSONAllPathsWithTypes('{"a" : ["Hello", 1, [1, 2, 3]]}'::JSON)

SELECT JSONAllPathsWithTypes(CAST('{"a" : ["Hello", 1, [1, 2, 3]]}', 'JSON'))

Query id: 0af75119-32bc-4224-b07e-c67e3de422fe

   ┌─JSONAllPathsWithTypes(CAST('{"a" : ["Hello", 1, [1, 2, 3]]}', 'JSON'))───┐
1. │ {'a':'Array(Dynamic)'} │
   └──────────────────────────────────────────────────────────────────────────┘

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

featurejsonIssues and pull-requests related to the new JSON data type

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions