2019-03-22 14:24:28 +00:00
#!/usr/bin/env bash
CURDIR = $( cd " $( dirname " ${ BASH_SOURCE [0] } " ) " && pwd )
2020-08-01 00:51:12 +00:00
. " $CURDIR " /../shell_config.sh
2019-03-22 14:24:28 +00:00
2019-04-16 14:13:13 +00:00
$CLICKHOUSE_CLIENT --query= "DROP TABLE IF EXISTS defaults"
2019-08-01 19:17:49 +00:00
$CLICKHOUSE_CLIENT --query= "CREATE TABLE defaults (x UInt32, y UInt32, a DEFAULT x + y, b Float32 DEFAULT round(log(1 + x + y), 5), c UInt32 DEFAULT 42, e MATERIALIZED x + y, f ALIAS x + y) ENGINE = Memory"
2019-03-22 14:24:28 +00:00
2019-10-11 13:34:26 +00:00
echo -ne '{"x":1, "y":1}\n' | ${ CLICKHOUSE_CURL } -sS " ${ CLICKHOUSE_URL } &query=INSERT%20INTO%20defaults%20FORMAT%20JSONEachRow%20SETTINGS%20input_format_defaults_for_omitted_fields=1 " --data-binary @-
echo -ne '{"x":2, "y":2, "c":2}\n' | ${ CLICKHOUSE_CURL } -sS " ${ CLICKHOUSE_URL } &query=INSERT+INTO+defaults+FORMAT+JSONEachRow+SETTINGS+input_format_defaults_for_omitted_fields=1 " --data-binary @-
2019-10-11 15:59:27 +00:00
echo -ne '{"x":3, "y":3, "a":3, "b":3, "c":3}\n' | ${ CLICKHOUSE_CURL } -sS " ${ CLICKHOUSE_URL } &database= ${ CLICKHOUSE_DATABASE } &query=INSERT+INTO+defaults+FORMAT+JSONEachRow+SETTINGS+input_format_defaults_for_omitted_fields=1 " --data-binary @-
echo -ne '{"x":4} {"y":5, "c":5} {"a":6, "b":6, "c":6}\n' | ${ CLICKHOUSE_CURL } -sS " ${ CLICKHOUSE_URL } &database= ${ CLICKHOUSE_DATABASE } &query=INSERT+INTO+defaults+FORMAT+JSONEachRow+SETTINGS+input_format_defaults_for_omitted_fields=1 " --data-binary @-
2019-03-22 14:24:28 +00:00
2019-04-16 14:13:13 +00:00
$CLICKHOUSE_CLIENT --query= "SELECT * FROM defaults ORDER BY x, y FORMAT JSONEachRow"
$CLICKHOUSE_CLIENT --query= "DROP TABLE defaults"