MaxGekk opened a new pull request #26582: [WIP][SPARK-29949][SQL][2.4] Fix formatting of timestamps by JSON/CSV datasources URL: https://github.com/apache/spark/pull/26582 ### What changes were proposed in this pull request? TODO ### Why are the changes needed? This fixes a bug of incorrectly formatting timestamps in microsecond precision. For example: ```scala Seq(java.sql.Timestamp.valueOf("2019-11-18 11:56:00.123456")).toDF("t") .select(to_json(struct($"t"), Map("timestampFormat" -> "yyyy-MM-dd HH:mm:ss.SSSSSS")).as("json")) .show(false) +----------------------------------+ |json | +----------------------------------+ |{"t":"2019-11-18 11:56:00.000123"}| +----------------------------------+ ``` ### Does this PR introduce any user-facing change? Yes. The example above outputs: ```scala +----------------------------------+ |json | +----------------------------------+ |{"t":"2019-11-18 11:56:00.123456"}| +----------------------------------+ ``` ### How was this patch tested? - By new tests for formatting by different patterns from `S` to `SSSSSS` in `DateTimeUtilsSuite` - A test for `to_json()` in `JsonFunctionsSuite` - A roundtrp test for writing and reading back a timestamp in a CSV file.
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
