Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-11798

Allow specification of 'time' column value as number in CQL query.

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Low
    • Resolution: Fixed
    • 3.0.8, 3.8
    • Legacy/CQL
    • 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).

      Attachments

        Activity

          People

            ifesdjeen Alex Petrov
            andrew.tolbert Andy Tolbert
            Alex Petrov
            Joshua McKenzie
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: