apla / node-clickhouse

Yandex ClickHouse driver for nodejs
MIT License
216 stars 50 forks source link

Support for Nested data type #63

Closed mikenikles closed 4 years ago

mikenikles commented 4 years ago

Hi,

One of my columns is of type Nested as described at https://clickhouse.tech/docs/en/sql-reference/data-types/nested-data-structures/nested/.

Are there any plans to support that?

Thanks,

Mike

nezed commented 4 years ago

As you can notice from documentation of Nested, its just a "syntax sugar". Nested columns is presented as column with type Array(x) and it name is prefixed with name of nested using dot separator.

example

This means that you are don’t need any specific support for Nested, and you can use any input/output format that supports arrays. JSONEachRow is good enough for most cases.

You can read more about working with Nested here:

Also you may be interested in input_format_import_nested_json=1, which just allows you to insert nested data as structured JSON.

In any case i recommend you not to store any key-value data using Nested.

This creates a lot of problems when selecting with data, and also this will lead to performance issues of queries. Just think about Nested as additional columns with type Array(x)

mikenikles commented 4 years ago

Thanks Dmitry, this is very helpful. After playing around, I found the links you shared and managed to insert nested data.

However, given your recommendation, I'll change that to individual columns. Very helpful, thanks for the detailed explanations.