andygrove opened a new pull request, #419: URL: https://github.com/apache/datafusion-spark/pull/419
## Which issue does this PR close? - None. This came out of the review of #391. ## Rationale for this change #391 runs the `.slt` files on Spark 3.5 as well as 4.2. Spark 3.5 does not parse `::`, so #391 added a rewriter to the PySpark runner that turns `expr::type` into `CAST(expr AS type)`. That rewriter has to find the operand of each `::`, which means reproducing a large part of Spark's expression grammar in Python: calls, subscripts, field access, window and `FILTER` clauses, `CASE`, interval literals, interval types, and so on. Review keeps finding more cases. Since the runner treats a parse error as a skip, every gap leaves a record unchecked on 3.5 without any report. `::` is also ambiguous between the engines this repository checks. DataFusion binds `::` tighter than a unary minus, so `-1::INT` is `-(1::INT)`. Spark 4 makes the sign part of the literal, so it is `CAST(-1 AS INT)`. The results are usually the same, but not always, for example at the integer boundaries (`-128::TINYINT`), which is why some files needed parentheses and a comment. Writing the casts as `CAST(x AS type)` removes both problems. DataFusion and every Spark version read the SQL the same way, and the runner does not need to rewrite it. ## What changes are included in this PR? - Every `::` cast in the SQL of the `.slt` records is now `CAST(x AS type)` (109 files). The rewrite was done mechanically and keeps DataFusion's precedence, so `-1.9::DOUBLE` became `-CAST(1.9 AS DOUBLE)`. The meaning of each query is unchanged. - A few comments and the READMEs no longer use `::`. The notes in `floor.slt` explaining why `(-128)::TINYINT` needed parentheses are gone, and `CAST((-128) AS TINYINT)` is now `CAST(-128 AS TINYINT)`. - The PySpark runner stops with an error if a record uses `::`. It checks every file before Spark starts, and points to the record. `::` in a string, a comment, an expected result or a commented-out record is not affected. - The runner's handling of `::` in `translate` and `_visible_type` is removed, since it can no longer be reached. Once this merges, #391 can drop its `::` rewriter. ## Are these changes tested? - `cargo test -p datafusion-spark-sqllogictest`: every file passes except `math/expm1.slt`, which fails the same way on `main` in my local run (`1.718281828459045` vs `1.7182818284590453`), so it is not related to this change. - The PySpark runner on Spark 4.2.0, on `main` and on this branch: 3181 pass, 273 expected failures, 631 skipped on both, and every record has the same outcome. - The runner's unit tests pass, with a new test for the `::` check. ## Are there any user-facing changes? No. For contributors, `.slt` files must use `CAST(x AS type)` rather than `x::type`, and the test README says so. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
