andygrove commented on code in PR #399:
URL: https://github.com/apache/datafusion-spark/pull/399#discussion_r4669572980


##########
crates/sqllogictest/test_files/datetime/add_months.slt:
##########
@@ -2,60 +2,73 @@
 # SPDX-FileCopyrightText: See the NOTICE file distributed with this work for 
additional information regarding copyright ownership
 # SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under 
one or more contributor license agreements
 
-# `add_months` has no `invoke_with_args` yet, so the records that call it are 
marked
-# `skipif evaluate` until 
https://github.com/apache/datafusion-spark/issues/312 is fixed.
-
-skipif evaluate
 query D
 SELECT add_months('2016-07-30'::date, 1::int);
 ----
 2016-08-30
 
-skipif evaluate
 query D
 SELECT add_months('2016-07-30'::date, 0::int);
 ----
 2016-07-30
 
-skipif evaluate
 query D
 SELECT add_months('2016-07-30'::date, 10000::int);
 ----
 2849-11-30
 
 # Test integer overflow
-skipif evaluate
 query error
 SELECT add_months('2016-07-30'::date, 2147483647::int);
 ----
 DataFusion error: Arrow error: Compute error: Date arithmetic overflow: 17012 
+ 2147483647 months
 
 
-skipif evaluate
 query D
 SELECT add_months('2016-07-30'::date, -5::int);
 ----
 2016-02-29
 
 # Test with NULL values
-skipif evaluate
 query D
 SELECT add_months(NULL::date, 1::int);
 ----
 NULL
 
-skipif evaluate
 query D
 SELECT add_months('2016-07-30'::date, NULL::int);
 ----
 NULL
 
-skipif evaluate
 query D
 SELECT add_months(NULL::date, NULL::int);
 ----
 NULL
 
+# Column arguments, with the day clamped to the end of a shorter month
+query D
+SELECT add_months(d, m) FROM VALUES
+  ('2016-07-30'::date, 1::int),
+  ('2016-08-31'::date, 1::int),
+  ('2024-01-31'::date, 1::int),
+  (NULL::date, 1::int),
+  ('2016-07-30'::date, NULL::int)
+  AS t(d, m);
+----
+2016-08-30
+2016-09-30
+2024-02-29
+NULL
+NULL
+
+# Scalar date with a column of months

Review Comment:
   Could we add the fourth shape too, a column of dates with a scalar month 
count? It's the form most queries use (`add_months(col, 1)`), and `evaluate` 
mode is new coverage for this function, so it would be nice to have all four 
combinations pinned. Something like:
   
   ```
   # Column of dates with a scalar month count
   query D
   SELECT add_months(d, 1::int) FROM VALUES ('2016-01-31'::date), 
('2016-02-29'::date), (NULL::date) AS t(d);
   ----
   2016-02-29
   2016-03-29
   NULL
   ```
   
   The `2016-02-29` row also pins that the result doesn't stick to the end of 
the month. I checked these values against Spark 4.2.0 and 3.5.9, and they pass 
in both modes here.



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