Search code examples
hbaseapache-zookeeperapache-phoenix

Timestamp format for phoenix upsert into hbase?


I am writing upsert script for phoenix to make the records in hbase.

CREATE TABLE IF NOT EXISTS temp.table (
id bigint(20),
created_at timestamp,
updated_at timestamp,
CONSTRAINT pk PRIMARY KEY (id)
);

And when I use upsert script

upsert into temp.table values(1000,'2014-07-30 13:33:45','2014-07-30 13:33:45');

I get the following error

Error: ERROR 203 (22005): Type mismatch. TIMESTAMP and VARCHAR for 2014-07-30 13:33:45 (state=22005,code=203)

And when I use

upsert into temp.table values(1000,13907665544,13907665544);

I get the error

Error: ERROR 203 (22005): Type mismatch. TIMESTAMP and LONG for 13907665544 (state=22005,code=203)

What is the other form to write upsert script when the columns has timestamp?


Solution

  • check your query once again. you should change your query from

    upsert into temp.test_table(1000,'2014-07-30 13:33:45','2014-07-30 13:33:45');
    

    to

    upsert into temp.test_table values (1000,'2014-07-30 13:33:45','2014-07-30 13:33:45');
    

    tested on sqlline version 1.1.8

    Also I have changed the table name from temp.table to temp.test_table as it was giving me the following error

    org.apache.phoenix.exception.PhoenixParserException: ERROR 604 (42P00): Syntax error. Mismatched input. Expecting "NAME", got "table" at line 1, column 33.
    

    1