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

Change default timestamp format to output only milliseconds, not microseconds

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Normal
    • Resolution: Fixed
    • Fix Version/s: 4.0-beta2, 4.0
    • Component/s: Tool/cqlsh
    • Labels:
    • Environment:

      Reproduced in trunk

      Description

      By default cqlsh outputs the timestamp column with microseconds precision, like this:

      cqlsh:test> create table t1(tm timestamp primary key, t text);
      cqlsh:test> insert into t1(tm, t) values(toTimestamp(now()), 't');
      cqlsh:test> insert into t1(tm, t) values(toTimestamp(now()), 't2');
      cqlsh:test> SELECT * from t1;
      
       tm                              | t
      ---------------------------------+----
       2018-10-27 18:01:54.738000+0000 | t2
       2018-10-27 18:01:52.599000+0000 |  t
      
      (2 rows)
      
      

      But if I want to use the value that is output on the screen in my query, I get an error:

      cqlsh:test> select * from t1 where tm = '2018-10-27 18:01:54.738000+0000';
      InvalidRequest: Error from server: code=2200 [Invalid query] message="Unable to coerce '2018-10-27 18:01:54.738000+0000' to a formatted date (long)"
      

      But if I manually round it to milliseconds, then everything works:

      cqlsh:test> select * from t1 where tm = '2018-10-27 18:01:54.738+0000';
      
       tm                              | t
      ---------------------------------+----
       2018-10-27 18:01:54.738000+0000 | t2
      
      (1 rows)
      

      It would be much easier user's experience if we use the same format for output & input data, because right now this leads to errors, that often not really understandable by novice users.

      P.S. I know about cqlshrc, but not every user has it configured.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                alexott Alex Ott
                Authors:
                Adam Holmberg
                Reviewers:
                Brandon Williams
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: