getting latest inserted object from riak timeseries

61 views Asked by At

Procedure to get latest record from Riak TS based on timestamp.

I created following table:

CREATE TABLE devicedetail (memberId SINT64 NOT NULL, type VARCHAR NOT NULL,model VARCHAR NOT NULL,imei VARCHAR NOT NULL,deviceId VARCHAR NOT NULL,manufacturer VARCHAR NOT NULL,os VARCHAR NOT NULL,version VARCHAR NOT NULL,time TIMESTAMP NOT NULL,PRIMARY KEY ((memberId),memberId));

Insert data using SQL:

INSERT INTO devicedetail VALUES (110,'health Kit','andorid-4.0','76565657675222','sdgsd1212','sony','windows','5.0',1420113600000);

and now I want to select deviceId based on latest inserted record:

select deviceId from devicedetail where memberId=110 and type='health Kit' order by time desc limit 1;

I am getting Exception like:

SQL Parser error {<<"order">>,riak_ql_parser, ["syntax error before: ","identifier"]}

but while querying:

select deviceId from devicedetail where memberId=110 and type='health Kit';

Getting Output as:

+---------+   
|deviceId |
+---------+
|sdgsd1212|
+---------+

Anyone knows how we get this in a simple way? Please tell me.

1

There are 1 answers

1
Craig On

Answer as of December 21, 2016:

Riak TS 1.5 was released this week. ORDER BY and LIMIT are now supported.

Old Answer:

ORDER BY is not supported in the current version of Riak TS (1.4) which is why you are getting the error. LIMIT is also not yet supported. ORDER BY and LIMIT will be included in the near future.