rdtr opened a new issue, #13528:
URL: https://github.com/apache/gluten/issues/13528

   ### Description
   
   With `spark.gluten.sql.ansiFallback.enabled=false`, an expression inside a 
view runs in the wrong ANSI mode on Velox.
   
   Spark resolves ANSI mode per expression during analysis (`failOnError`, 
`ansiEnabled`, `EvalMode`), and a view keeps the mode it was created with 
(SPARK-33141; since Spark 4.0 the ANSI setting is always captured, 
SPARK-53348). So after an upgrade to Spark 4, a query over a view created with 
ANSI off runs the view's expressions with ANSI off and the rest with ANSI on.
   
   Velox's Spark functions that read `spark.ansi_enabled` from the query config 
(`abs`, `unaryminus`, `remainder`, `pmod`, integral `round`, `conv`, `elt`, 
`make_date`, `make_timestamp`, `unix_timestamp`, `get_timestamp`, `next_day`, 
`element_at`, `sum`, `avg`, ...) run in the session's mode regardless, so the 
result differs from Spark:
   
   ```sql
   SET spark.sql.ansi.enabled=false;
   CREATE TEMP VIEW v AS SELECT abs(c) AS a FROM t;   -- t has c = -2147483648
   SET spark.sql.ansi.enabled=true;
   SELECT a FROM v;   -- Spark: -2147483648 (the view keeps ANSI off); Velox: 
ARITHMETIC_OVERFLOW
   ```
   
   Per the direction agreed in 
https://github.com/facebookincubator/velox/issues/3869, Velox functions keep 
reading the session config, and Gluten falls back when the mode captured in an 
expression differs from the session's. `array[index]` with ANSI on is also 
affected today: it maps to Velox's `get`, which never throws.
   
   ### Gluten version
   
   None


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