andygrove opened a new issue, #6217:
URL: https://github.com/apache/datafusion-comet/issues/6217

   ### Describe the bug
   
   Two error-fidelity items from #5071 are still open. That issue was closed 
automatically when #5162 merged, because #5162's description mentions it next 
to a closing keyword. The other #5071 items have since been fixed. The 
compatibility guide lists these two divergences and links here.
   
   1. **Byte / Short overflow raises the wrong error class.** Under ANSI mode, 
`Add`, `Subtract` and `Multiply` on `TINYINT` / `SMALLINT` overflow raise 
`BINARY_ARITHMETIC_OVERFLOW` in Spark, carrying both operand values and the 
operator symbol. Comet raises `ARITHMETIC_OVERFLOW` with `byte overflow` / 
`short overflow`, because 
`native/spark-expr/src/math_funcs/checked_arithmetic.rs` builds 
`SparkError::ArithmeticOverflow` for every integer width. 
`SparkError::BinaryArithmeticOverflow` already exists in 
`native/common/src/error.rs`, and every `ShimSparkErrorConverter` maps it to 
`QueryExecutionErrors.binaryArithmeticCauseOverflowError`, but no kernel 
constructs it.
   2. **Integral `ARITHMETIC_OVERFLOW` messages omit the `try_` suggestion.** 
Each `ShimSparkErrorConverter` passes `""` as the suggested function to 
`QueryExecutionErrors.arithmeticOverflowError`, so Comet's message leaves out 
Spark's ``Use `try_add` to tolerate overflow and return NULL instead.``
   
   Comet's decision to throw matches Spark. Only the error class and message 
differ, which matters to code that inspects the exception class, 
`getCondition()`, or the message.
   
   ### Steps to reproduce
   
   The operands have to come from a table, since Spark constant-folds 
literal-only arithmetic before Comet sees it.
   
   ```sql
   SET spark.sql.ansi.enabled=true;
   CREATE TABLE t (b TINYINT, l BIGINT) USING parquet;
   INSERT INTO t VALUES (127, 9223372036854775807);
   SELECT b + CAST(1 AS TINYINT) FROM t; -- Spark: BINARY_ARITHMETIC_OVERFLOW; 
Comet: ARITHMETIC_OVERFLOW "byte overflow"
   SELECT l + 1 FROM t;                  -- Spark's message suggests try_add; 
Comet's does not
   ```
   
   ### Expected behavior
   
   The error class, the message parameters, and the `try_` suggestion match 
Spark.
   
   ### Additional context
   
   Part of #5078. Found during the 1.1.0 user guide review (#6168, #6169).
   


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