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

Incorrect parsing of the timestamp with less than 3 digits in the milliseconds

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Normal
    • Resolution: Fixed
    • 4.0-beta2, 4.0
    • CQL/Interpreter
    • None
    • Correctness - API / Semantic Implementation
    • Normal
    • Normal
    • User Report
    • All
    • Docs
    • Hide

      Unit tests were expanded and made more rigorous.

       

      Doc: may need to visit CQL timestamp discussion and see if there is any mention of this limitation.

      Show
      Unit tests were expanded and made more rigorous.   Doc: may need to visit CQL timestamp discussion and see if there is any mention of this limitation.

    Description

      (tested on 4.0-beta1, but should be in all versions)

      Right now, Cassandra incorrectly handles timestamps with less than 3 digits in the milliseconds part. Timestamps (valid from the Java point of view (see below output in Scala) are either rejected (if we have 1 digit only), or incorrectly parsed when 2 digits are specified:

      cqlsh> create table test.tm (id int primary key, tm timestamp);
      cqlsh> insert into test.tm(id, tm) values (2, '2020-07-24T10:00:01.2Z');
      InvalidRequest: Error from server: code=2200 [Invalid query] message="Unable to coerce '2020-07-24T10:00:01.2Z' to a formatted date (long)"
      cqlsh> insert into test.tm(id, tm) values (1, '2020-07-24T10:00:01.12Z');
      cqlsh> select * from test.tm;
      
       id | tm
      ----+---------------------------------
        1 | 2020-07-24 10:00:01.012000+0000
      
      (1 rows)
      

      Checking with Instant:

      scala> java.time.Instant.parse("2020-07-24T10:00:01.12Z")
      res0: java.time.Instant = 2020-07-24T10:00:01.120Z
      scala> java.time.Instant.parse("2020-07-24T10:00:01.2Z")
      res1: java.time.Instant = 2020-07-24T10:00:01.200Z
      

      Imho it should be fixed (Cc: aholmber)

      Attachments

        Issue Links

          Activity

            People

              aholmber Adam Holmberg
              alexott Alex Ott
              Adam Holmberg
              Brandon Williams
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: