Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-17914

Spark SQL casting to TimestampType with nanosecond results in incorrect timestamp

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.6.1
    • Fix Version/s: 2.2.0, 2.3.0
    • Component/s: SQL
    • Labels:
      None

      Description

      In some cases when timestamps contain nanoseconds they will be parsed incorrectly.

      Examples:

      "2016-05-14T15:12:14.0034567Z" -> "2016-05-14 15:12:14.034567"
      "2016-05-14T15:12:14.000345678Z" -> "2016-05-14 15:12:14.345678"

      The issue seems to be happening in DateTimeUtils.stringToTimestamp(). It assumes that only 6 digit fraction of a second will be passed.

      With this being the case I would suggest either discarding nanoseconds automatically, or throw an exception prompting to pre-format timestamps to microsecond precision first before casting to the Timestamp.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                aokolnychyi Anton Okolnychyi
                Reporter:
                oromankova@cardlytics.com Oksana Romankova
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: