andygrove opened a new issue, #3055: URL: https://github.com/apache/datafusion-sqlparser-rs/issues/3055
In Spark SQL, the sign of a number literal is part of the literal ([`number` rule](https://github.com/apache/spark/blob/master/sql/api/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBaseParser.g4): `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: ```sql 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), .. }`. -- 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]
