andygrove commented on code in PR #5039:
URL: https://github.com/apache/datafusion-comet/pull/5039#discussion_r3659505430


##########
spark/src/test/resources/sql-tests/expressions/datetime/make_interval.sql:
##########
@@ -0,0 +1,46 @@
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements.  See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership.  The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License.  You may obtain a copy of the License at
+--
+--   http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing,
+-- software distributed under the License is distributed on an
+-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+-- KIND, either express or implied.  See the License for the
+-- specific language governing permissions and limitations
+-- under the License.
+
+-- Config: spark.comet.exec.scalaUDF.codegen.enabled=false
+
+statement
+CREATE TABLE test_make_interval(
+  years int,
+  months int,
+  weeks int,
+  days int,
+  hours int,
+  mins int,
+  secs decimal(38, 6)) USING parquet
+
+statement
+INSERT INTO test_make_interval VALUES
+  (1, 2, 3, 4, 5, 6, 7.123456),
+  (0, 1, 0, 1, 0, 0, 100.000001),
+  (-1, -2, -1, -1, -1, -1, -1.500000),
+  (NULL, 1, 2, 3, 4, 5, 6.000000)
+
+query
+SELECT make_interval(years, months, weeks, days, hours, mins, secs)
+FROM test_make_interval
+ORDER BY years
+
+query
+SELECT make_interval(1, 2), make_interval(3), make_interval()
+
+query
+SELECT make_interval(2147483647)

Review Comment:
   It might be worth expanding coverage here. A few things Spark's own 
`IntervalExpressionsSuite` / `interval.sql` exercise that aren't covered yet:
   
   - Microsecond-precision seconds like Spark's docstring example 
`make_interval(0, 1, 0, 1, 0, 0, 100.000001)` asserted directly (it's currently 
only exercised via the column path where it can be hard to spot a per-row 
precision drift).
   - Nulls in components other than `years` in the column path (currently only 
the `years=NULL` row is tested).
   - Large-second cases from Spark's `interval.sql`: `make_interval(1, 2, 3, 4, 
0, 0, 123456789012.123456)` and `make_interval(0, 0, 0, 0, 0, 0, 
1234567890123456789)`. If either is a known divergence (see the nanos-overflow 
comment on the Rust file), wrapping them in `query ignore(<tracking issue>)` 
would at least pin the behavior for future readers.
   - `Int.MinValue` for a signed-overflow smoke test on the years column.



##########
spark/src/test/resources/sql-tests/expressions/datetime/make_interval_ansi.sql:
##########
@@ -0,0 +1,35 @@
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements.  See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership.  The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License.  You may obtain a copy of the License at
+--
+--   http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing,
+-- software distributed under the License is distributed on an
+-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+-- KIND, either express or implied.  See the License for the
+-- specific language governing permissions and limitations
+-- under the License.
+
+-- Native ANSI execution must preserve Spark's overflow exception.
+-- Config: spark.sql.ansi.enabled=true
+-- Config: spark.comet.exec.scalaUDF.codegen.enabled=false
+
+statement
+CREATE TABLE test_make_interval_ansi(years int) USING parquet
+
+statement
+INSERT INTO test_make_interval_ansi VALUES (NULL)
+
+query
+SELECT make_interval(1, 2, 3, 4, 5, 6, 7.123456)
+
+query
+SELECT make_interval(years) FROM test_make_interval_ansi
+
+query expect_error(overflow)
+SELECT make_interval(2147483647)

Review Comment:
   Consider adding ANSI overflow tests for components other than `years` — the 
current fixture only exercises `years = Int.MaxValue`. Spark's 
`IntervalExpressionsSuite` ANSI mode block covers `weeks = Int.MaxValue`, and 
per-row overflow via `hours`/`mins`/`seconds` interactions. Something like:
   
   ```sql
   query expect_error(overflow)
   SELECT make_interval(0, 0, 2147483647)
   ```
   
   would confirm the overflow detection path fires on non-`years` components 
too.



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