MaxGekk commented on code in PR #56593:
URL: https://github.com/apache/spark/pull/56593#discussion_r3437206525
##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/DateExpressionsSuite.scala:
##########
@@ -1067,6 +1067,41 @@ class DateExpressionsSuite extends SparkFunSuite with
ExpressionEvalHelper {
ToUnixTimestamp(Literal("2015-07-24"), Literal("\""), UTC_OPT) :: Nil)
}
+ test("SPARK-57528: unix_timestamp / to_unix_timestamp over
nanosecond-precision timestamps") {
+ import org.apache.spark.sql.catalyst.util.TimestampNanosTestUtils._
+ // The format is ignored for the timestamp-argument form; the result is
always whole-second
+ // BIGINT, so the sub-second digits never affect it.
+ val fmt = Literal("yyyy-MM-dd HH:mm:ss")
Review Comment:
Good catch, thanks. Fixed in ce2a485: I added a case that runs the NTZ/LTZ
assertions across `p in {7, 8, 9}` with a deliberately invalid format
(`Literal("not-a-format")`) and asserts the same whole-second result, which
actually pins the "format ignored" contract for the timestamp-argument form. I
also dropped the now-redundant comment.
Minor note: the micros path doesn't actually have an
invalid-format-with-timestamp assertion either (the cases around `:1021` use
valid formats too), so this strengthens the contract on the nanos side
regardless.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]