Clickhouse: INSERT with JSONEachRow format does not use DEFAULT value for the Date column

Created on 7 Feb 2018  Â·  3Comments  Â·  Source: ClickHouse/ClickHouse

Hi,

Just faced with the issue where using clickhouse-client/HTTP-interface I was unable to populate a column with default value calculated with a function toDate(.

Conditions

Table schema:

CREATE TABLE timeseq
(
    `_time` DateTime,
    `_date` Date default toDate(`_time`),

    body String
) ENGINE = MergeTree(`_date`, (`_time`), 8192)

The query which we are going to use in order to insert test data:

echo '{"_time":"2018-02-07T11:33:14","body":"something here"}' | clickhouse-client -q "INSERT INTO timeseq FORMAT JSONEachRow"

Expectations:
We expect that once the row is inserted into the table there will be _date field populated with value '2018-02-07'.

Issue

Our expectations are not met. Once the query is executed there is a row created in table 'timeseq' but field _date is populated with '0000-00-00' value instead of the one given in the dataset.

Note: We also tried to do the same insert query using CSV format and make the data CSV-compatible. In this case _date field was populated correctly.

Hope that is clear enough.

Thanks!

Most helpful comment

Works in master (with setting insert_sample_with_metadata set).

echo '{"_time":"2018-02-07T11:33:14","body":"something here"}' | ./clickhouse-client --insert_sample_with_metadata=1 -q "INSERT INTO timeseq FORMAT JSONEachRow"

./clickhouse-client -q 'select * from timeseq'
2018-02-07 11:33:14     2018-02-07      something here

All 3 comments

https://github.com/arkhipov is going to do this.

Works in master (with setting insert_sample_with_metadata set).

echo '{"_time":"2018-02-07T11:33:14","body":"something here"}' | ./clickhouse-client --insert_sample_with_metadata=1 -q "INSERT INTO timeseq FORMAT JSONEachRow"

./clickhouse-client -q 'select * from timeseq'
2018-02-07 11:33:14     2018-02-07      something here
Was this page helpful?
0 / 5 - 0 ratings