Nested data structure in migration from mongoDB to clickhouse

1.2k views Asked by At

In my mongoDB, there are nested data structures with three different levels, as the pictures are shown . Since mongo engine in clickhouse doesn't support such structures, I try to define these fields as String when creating table using mongoDB engine, but failed to retrieve data. Should I predefine new tables(normalise each nested structure) and then insert values from mongo to CH? Do you have alternatives?

1st nested structure

2nd nested structure

3rd nested structure

1

There are 1 answers

0
ramazan polat On

From https://clickhouse.tech/docs/en/engines/table-engines/integrations/mongodb/

MongoDB Engine supports only non-nested data types.

You can use Map data type if you can flatten the schema of the MongoDB collection.

Alternatively, you can save the whole document (JSON) as String and work on it with JSON functions.