clickhouse_fdw icon indicating copy to clipboard operation
clickhouse_fdw copied to clipboard

Could not map type <'json')>

Open iosifnicolae2 opened this issue 3 years ago • 1 comments

  • Clickhouse table:
CREATE TABLE default.unit_records
(
    `unit_id` String,
    `timestamp` DateTime,
    `data` Object('json')
)
ENGINE = MergeTree
PRIMARY KEY (unit_id, timestamp)
ORDER BY (unit_id, timestamp)
SETTINGS index_granularity = 8192
  • trying to run:
IMPORT FOREIGN SCHEMA "default" FROM SERVER clickhouse_svr INTO clickhouse;
  • we're getting:
ERROR:  clickhouse_fdw: could not map type <'json')>
SQL state: XX000

@ildus how can i implement proper mapping for json type?

Many thanks!

EDIT I will try to add the mapping here, hope it solves the problem :) https://github.com/adjust/clickhouse_fdw/blob/fd1f3ec585b73ed61afcd3334db535e79969fb83/src/pglink.c#L735

iosifnicolae2 avatar Jun 16 '22 08:06 iosifnicolae2

I've implemented a quick fix here: https://github.com/adjust/clickhouse_fdw/pull/88 (this PR must be checked also on an instance without allow_experimental_object_type option enabled)

After merging this PR you will be able to query json fields as below:

SELECT "data.field" FROM clickhouse.unit_records;

iosifnicolae2 avatar Jun 16 '22 13:06 iosifnicolae2