Cassandra
  1. Cassandra
  2. CASSANDRA-6212

TimestampType doesn't support pre-epoch long

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Fix Version/s: 2.0.2
    • Component/s: API, Core
    • Labels:
      None

      Description

      org.apache.cassandra.db.marshal.TimestampType.dateStringToTimestamp() contains a regular expression that checks to see if the String argument contains a number. If so it parses it as a long timestamp. However pre-epoch timestamps are negative and the code doesn't account for this so it tries to parse it as a formatted Date. A tweak to the regular expression in TimestampType.dateStringToTimestamp() would solve this issue.

      I could use formatted date strings instead, but the TimestampType date parser uses ISO8601 patterns which would cause the timestamp to be rounded to the nearest second.

      Currently I get the following exception message:

      unable to coerce '-86400000' to a formatted date (long)

        Activity

        Hide
        Jonathan Ellis added a comment -

        Can you take a stab at this, Mikhail?

        Show
        Jonathan Ellis added a comment - Can you take a stab at this, Mikhail?
        Hide
        Mikhail Stepura added a comment -

        Changed the regexp to accept a leading "-"

        Show
        Mikhail Stepura added a comment - Changed the regexp to accept a leading "-"
        Hide
        Aleksey Yeschenko added a comment -

        Thanks, committed.

        Haven't included the unit test, though - this particular one is better suited for the dtests.

        Show
        Aleksey Yeschenko added a comment - Thanks, committed. Haven't included the unit test, though - this particular one is better suited for the dtests.
        Hide
        Simon Hopkin added a comment -

        Thanks for the quick turnaround on this issue guys.

        Show
        Simon Hopkin added a comment - Thanks for the quick turnaround on this issue guys.

          People

          • Assignee:
            Mikhail Stepura
            Reporter:
            Simon Hopkin
            Reviewer:
            Aleksey Yeschenko
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development