You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Spark dialect: a minus sign before a number literal should bind tighter than :: #3055
In Spark SQL, the sign of a number literal is part of the literal (number rule: MINUS? INTEGER_VALUE, MINUS? DECIMAL_VALUE, ...). So -128::TINYINT is CAST(-128 AS TINYINT). SparkSqlDialect parses it as -(128::TINYINT), as the generic dialect does.
With DataFusion on the Spark dialect:
SELECT-128::TINYINT;
-- Arrow error: Cast error: Can't cast value 128 to type Int8
Spark 4.2 returns -128. The same happens for -2147483648::INT and -9223372036854775808::BIGINT. A sign before anything other than a number literal is a unary minus in Spark too, so -a::INT and -(1)::INT already parse correctly as -(a::INT) and -((1)::INT).
Expected: in SparkSqlDialect, a - directly before a numeric literal is part of the literal for the :: that follows, so -128::TINYINT parses as Cast { expr: Value(-128), .. }.
Activity