Skip to content

Commit db81fa6

Browse files
committed
[SPARK-57560][SQL][TEST][FOLLOWUP] Update the Java 21 golden file for TIME try arithmetic tests
### What changes were proposed in this pull request? This is a follow-up of #56819, addressing the Java 21/25 build failures reported there. #56819 added TIME cases to `try_arithmetic.sql` and regenerated the base golden files. However, `nonansi/try_arithmetic.sql.out` has a Java-21-specific variant `nonansi/try_arithmetic.sql.out.java21` (the suite reads it when `Utils.isJavaVersionAtLeast21`, because JDK-4511638 changes the `toString` of `Float`/`Double`). That `.java21` variant was left stale -- it was missing the new TIME rows -- so on Java 21+ the test compared actual output (with TIME rows) against the stale golden file and failed. This PR adds the new TIME rows to `nonansi/try_arithmetic.sql.out.java21`. The only genuine Java 21 difference in this file remains the `try_divide(1, (2147483647 + 1))` double output: - Java 8/11/17: `-4.6566128730773926E-10` - Java 21+: `-4.656612873077393E-10` The new TIME outputs (time values, NULLs, and day-time intervals) are Java-version stable, so they are identical in the base and `.java21` files. The ANSI `try_arithmetic.sql.out` needs no `.java21` variant because that `try_divide` double query only appears in non-ANSI mode (in ANSI mode the inner `2147483647 + 1` overflows). ### Why are the changes needed? To fix the Java 21/25 build failures observed after #56819 was merged, e.g.: - https://github.com/apache/spark/actions/runs/28359601002/job/84013737500 - https://github.com/apache/spark/actions/runs/28406731869/job/84173152434 ### Does this PR introduce _any_ user-facing change? No. Test-only. ### How was this patch tested? - Verified `nonansi/try_arithmetic.sql.out.java21` differs from the base `nonansi/try_arithmetic.sql.out` by exactly the one `try_divide` double line, consistent with the existing Java 21 golden file convention. - `build/sbt 'sql/testOnly org.apache.spark.sql.SQLQueryTestSuite -- -z try_arithmetic'` ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Cursor Closes #56894 from MaxGekk/time-try-eval-java21. Authored-by: Maxim Gekk <max.gekk@gmail.com> Signed-off-by: Max Gekk <max.gekk@gmail.com>
1 parent 1409d88 commit db81fa6

1 file changed

Lines changed: 104 additions & 0 deletions

File tree

sql/core/src/test/resources/sql-tests/results/nonansi/try_arithmetic.sql.out.java21

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,54 @@ struct<try_add(INTERVAL '02' SECOND, TIMESTAMP_NTZ '2021-01-01 00:00:00'):timest
167167
2021-01-01 00:00:02
168168

169169

170+
-- !query
171+
SELECT try_add(time'08:00:00', interval 1 hour)
172+
-- !query schema
173+
struct<try_add(TIME '08:00:00', INTERVAL '01' HOUR):time(6)>
174+
-- !query output
175+
09:00:00
176+
177+
178+
-- !query
179+
SELECT try_add(interval 1 hour, time'08:00:00')
180+
-- !query schema
181+
struct<try_add(INTERVAL '01' HOUR, TIME '08:00:00'):time(6)>
182+
-- !query output
183+
09:00:00
184+
185+
186+
-- !query
187+
SELECT try_add(time'23:59:59.999999', interval 1 hour)
188+
-- !query schema
189+
struct<try_add(TIME '23:59:59.999999', INTERVAL '01' HOUR):time(6)>
190+
-- !query output
191+
NULL
192+
193+
194+
-- !query
195+
SELECT try_add(time'00:00:00', interval -1 second)
196+
-- !query schema
197+
struct<try_add(TIME '00:00:00', INTERVAL '-01' SECOND):time(6)>
198+
-- !query output
199+
NULL
200+
201+
202+
-- !query
203+
SELECT try_add(time'08:30:00', null)
204+
-- !query schema
205+
struct<try_add(TIME '08:30:00', NULL):time(6)>
206+
-- !query output
207+
NULL
208+
209+
210+
-- !query
211+
SELECT try_add(null, interval 1 hour)
212+
-- !query schema
213+
struct<try_add(NULL, INTERVAL '01' HOUR):interval hour>
214+
-- !query output
215+
NULL
216+
217+
170218
-- !query
171219
SELECT try_add(interval 2 year, interval 2 year)
172220
-- !query schema
@@ -465,6 +513,62 @@ struct<try_subtract(INTERVAL '106751991' DAY, INTERVAL '-3' DAY):interval day>
465513
NULL
466514

467515

516+
-- !query
517+
SELECT try_subtract(time'10:00:00', interval 1 hour)
518+
-- !query schema
519+
struct<try_subtract(TIME '10:00:00', INTERVAL '01' HOUR):time(6)>
520+
-- !query output
521+
09:00:00
522+
523+
524+
-- !query
525+
SELECT try_subtract(time'00:30:00', interval 1 hour)
526+
-- !query schema
527+
struct<try_subtract(TIME '00:30:00', INTERVAL '01' HOUR):time(6)>
528+
-- !query output
529+
NULL
530+
531+
532+
-- !query
533+
SELECT try_subtract(time'00:00:00', interval 1 second)
534+
-- !query schema
535+
struct<try_subtract(TIME '00:00:00', INTERVAL '01' SECOND):time(6)>
536+
-- !query output
537+
NULL
538+
539+
540+
-- !query
541+
SELECT try_subtract(time'10:00:00', null)
542+
-- !query schema
543+
struct<try_subtract(TIME '10:00:00', NULL):interval hour to second>
544+
-- !query output
545+
NULL
546+
547+
548+
-- !query
549+
SELECT try_subtract(time'10:00:00', time'08:00:00')
550+
-- !query schema
551+
struct<try_subtract(TIME '10:00:00', TIME '08:00:00'):interval hour to second>
552+
-- !query output
553+
0 02:00:00.000000000
554+
555+
556+
-- !query
557+
SELECT try_subtract(time'08:00:00.123456', time'10:00:00')
558+
-- !query schema
559+
struct<try_subtract(TIME '08:00:00.123456', TIME '10:00:00'):interval hour to second>
560+
-- !query output
561+
-0 01:59:59.876544000
562+
563+
564+
-- !query
565+
SELECT try_subtract(null, time'08:00:00')
566+
-- !query schema
567+
struct<try_subtract(NULL, TIME '08:00:00'):interval hour to second>
568+
-- !query output
569+
NULL
570+
571+
468572
-- !query
469573
SELECT try_multiply(2, 3)
470574
-- !query schema

0 commit comments

Comments
 (0)