apacheapache-kudu

Timestamp Primary key Kudu


I am trying to load data into Kudu table through envelope. One of the primary key column is timestamp. DDL : CREATE TABLE BAL ( client_id int bal_id int, effective_time timestamp, prsn_id int, bal_amount double, prsn_name string, PRIMARY KEY (client_id, bal_id, effective_time) ) PARTITION BY HASH(client_id) PARTITIONS 8 STORED AS KUDU;

But It is throwing error Java.lang.illelegalArgumentException

So my question is simple - timestamp column could be part of primary key or not??


Solution

  • Yes it is perfectly alright to include timestamp as part of primary key. Please find the code:

    use ${var:db_name};
    CREATE TABLE test (
      table_name STRING NOT NULL ENCODING AUTO_ENCODING COMPRESSION DEFAULT_COMPRESSION,
      table_id BIGINT NOT NULL ENCODING AUTO_ENCODING COMPRESSION DEFAULT_COMPRESSION,
      last_read_timestamp TIMESTAMP NOT NULL ENCODING AUTO_ENCODING COMPRESSION DEFAULT_COMPRESSION,
      window STRING NOT NULL ENCODING AUTO_ENCODING COMPRESSION DEFAULT_COMPRESSION,
      ext_gen_timestamp timestamp NOT NULL ENCODING AUTO_ENCODING COMPRESSION DEFAULT_COMPRESSION,
      extract_date timestamp NOT NULL ENCODING AUTO_ENCODING COMPRESSION DEFAULT_COMPRESSION,
      manual_rerun STRING NULL ENCODING AUTO_ENCODING COMPRESSION DEFAULT_COMPRESSION,
      PRIMARY KEY (table_name, table_id, last_read_timestamp)
    )
    STORED AS KUDU;
    

    *