MaxGekk opened a new pull request, #56562: URL: https://github.com/apache/spark/pull/56562
### What changes were proposed in this pull request? This PR adds support for `TIMESTAMP_NTZ(p)` / `TIMESTAMP_LTZ(p)` (`p in [7, 9]`) in `+/- ANSI day-time interval` arithmetic. Concretely: - Extends `TimestampAddInterval` input typing to accept nanos timestamp types alongside existing microsecond timestamp types. - Adds nanos-aware execution/codegen paths for day-time and calendar-interval arithmetic that preserve `nanosWithinMicro` while applying interval arithmetic on epoch micros. - Adds utility helpers in `DateTimeUtils` to keep nanos remainder unchanged during timestamp +/- interval operations. - Adds catalyst and SQL test coverage for NTZ/LTZ nanos interval arithmetic parity. - Regenerates impacted SQL golden files. A small follow-up commit in this branch removes temporary helper abstractions (`AnyTimestampFamilyType` / `AnyTimestampFamilyTypeExpression`) and keeps the change scoped without widening `SubtractTimestamps` handling. ### Why are the changes needed? Spark already supports timestamp +/- ANSI day-time interval for microsecond timestamp families, but nanos timestamp families (`TIMESTAMP_NTZ(p)` / `TIMESTAMP_LTZ(p)`, `p in [7, 9]`) lacked parity. This left valid datetime arithmetic unsupported for nanos types. These changes close that parity gap while preserving nanos precision semantics and existing LTZ/NTZ timezone behavior. ### Does this PR introduce _any_ user-facing change? Yes. `TIMESTAMP_NTZ(p)` / `TIMESTAMP_LTZ(p)` (`p in [7, 9]`) now support `+/- ANSI day-time interval` arithmetic. Examples: - `TIMESTAMP_NTZ '2020-01-02 03:04:05.123456789' + INTERVAL '2 00:03:00.000456' DAY TO SECOND` - `TIMESTAMP_LTZ '2020-01-02 03:04:05.123456789 UTC' - INTERVAL '1 00:04:00.000321' DAY TO SECOND` ### How was this patch tested? - `build/sbt 'catalyst/testOnly org.apache.spark.sql.catalyst.expressions.DateExpressionsSuite'` - `SPARK_GENERATE_GOLDEN_FILES=1 build/sbt 'sql/testOnly org.apache.spark.sql.SQLQueryTestSuite -- -z "timestamp-ntz-nanos"'` - `SPARK_GENERATE_GOLDEN_FILES=1 build/sbt 'sql/testOnly org.apache.spark.sql.SQLQueryTestSuite -- -z "timestamp-ltz-nanos"'` - `./dev/scalastyle` - `./build/mvn scalafmt:format -Dscalafmt.skip=false -Dscalafmt.validateOnly=false -Dscalafmt.changedOnly=false -pl sql/api -pl sql/connect/common -pl sql/connect/server -pl sql/connect/shims -pl sql/connect/client/jvm` ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Cursor Codex 5.3 -- 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]
