Details
-
Improvement
-
Status: Resolved
-
Low
-
Resolution: Fixed
-
None
Description
The 'time' cql type is internally stored and sent over the protocol as an 8-byte long value representing nanoseconds since midnight.
When specifying a time column value as a number in a simple statement,, C* currently responds with:
InvalidRequest: code=2200 [Invalid query] message="Invalid INTEGER constant (42000000000) for "time" of type time"
Instead one must provide this value as a string (i.e. '42000000000') or use an HH.MM.SS.sssssssss format (i.e. '00:00:42.000000000'). It would be nice if it supported unquoted numbers as well.
Example:
cqlsh:simple> CREATE TABLE timeentity (id varchar PRIMARY KEY, time time); # Doesn't work cqlsh:simple> INSERT into timeentity (id, time) values ('1', 42000000000); InvalidRequest: code=2200 [Invalid query] message="Invalid INTEGER constant (42000000000) for "time" of type time" # Works cqlsh:simple> INSERT into timeentity (id, time) values ('1', '42000000000');
When using prepared statements or simple statements with parameters, one could provide a long value, depending on the driver implementation. I.E. the java driver has setTime(int index, long v).