Skip to content

Instantly share code, notes, and snippets.

@chaudum
Created October 24, 2017 15:45
Show Gist options
  • Save chaudum/b1774afdbe5c03067bd967d3c9cb1730 to your computer and use it in GitHub Desktop.
Save chaudum/b1774afdbe5c03067bd967d3c9cb1730 to your computer and use it in GitHub Desktop.
CREATE TABLE t_a (
ts TIMESTAMP,
hash STRING,
granularity STRING,
value FLOAT,
part_key__generated TIMESTAMP GENERATED ALWAYS AS date_trunc(granularity, ts)
) PARTITIONED BY (granularity, part_key__generated);
INSERT INTO t_a (ts, hash, granularity, value) VALUES (1508848674000, 'abc', 'day', 0.1);
CREATE TABLE t_b (
ts TIMESTAMP,
hash STRING,
granularity STRING,
value FLOAT,
part_key__generated TIMESTAMP GENERATED ALWAYS AS date_trunc(granularity, ts),
PRIMARY KEY (ts, hash, granularity, part_key__generated)
) PARTITIONED BY (granularity, part_key__generated);
INSERT INTO t_b (ts, hash, granularity, value) VALUES (1508848674000, 'abc', 'day', 0.1);
$ crash --hosts st1.p.fir.io:4200 < test.sql
CONNECT OK
CREATE OK, 1 row affected (0.048 sec)
INSERT OK, 1 row affected (1.006 sec)
CREATE OK, 1 row affected (0.049 sec)
SQLActionException[SQLParseException: Primary key value must not be NULL]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment