MaxGekk opened a new pull request, #56819:
URL: https://github.com/apache/spark/pull/56819

   ### What changes were proposed in this pull request?
   This PR adds TRY-mode coverage for TIME datetime arithmetic.
   
   `try_add`/`try_subtract` over TIME values (`TIME +/- day-time INTERVAL`, and 
`TIME - TIME`) flow through the existing generic `TryEval(Add/Subtract(..., 
EvalMode.ANSI))` fallback in `TryEval`. Because `InheritAnalysisRules` exposes 
the replacement as a child, `BinaryArithmeticWithDatetimeResolver` already 
resolves the inner `Add`/`Subtract` to `TimeAddInterval`/`SubtractTimes`, and 
`TryEval` suppresses the resulting `DATETIME_OVERFLOW` to NULL. This is the 
same mechanism used for `TIMESTAMP`/`DATE` try arithmetic, so no production 
behavior change is required.
   
   Concretely, this PR:
   - Adds `try_add`/`try_subtract` TIME cases to `try_arithmetic.sql` (happy 
path, overflow/underflow to NULL, NULL propagation, and `TIME - TIME` returning 
a day-time interval) and regenerates the golden files (including the `nonansi` 
and `analyzer-results` variants).
   - Adds TIME examples to the `try_add`/`try_subtract` 
`@ExpressionDescription`.
   
   ### Why are the changes needed?
   `TryEval` carried a TODO to support TRY eval mode on datetime arithmetic 
expressions. TIME arithmetic (`TimeAddInterval`, `SubtractTimes`) is in this 
family; without explicit coverage, `try_*` usage over TIME was untested. This 
guarantees that TRY-mode TIME arithmetic returns NULL (not an error) on 
out-of-range results, consistent with the other datetime types.
   
   ### Does this PR introduce _any_ user-facing change?
   No behavior change. It adds tests and documentation examples for 
`try_add`/`try_subtract` over TIME.
   
   ### How was this patch tested?
   - Added cases to `try_arithmetic.sql` and regenerated golden files.
   - `build/sbt 'sql/testOnly org.apache.spark.sql.SQLQueryTestSuite -- -z 
try_arithmetic'`
   - `build/sbt 'sql/testOnly 
org.apache.spark.sql.expressions.ExpressionInfoSuite -- -z "check outputs of 
expression examples"'`
   
   ### Was this patch authored or co-authored using generative AI tooling?
   Generated-by: Cursor


-- 
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]

Reply via email to