andygrove opened a new pull request, #316:
URL: https://github.com/apache/datafusion-spark/pull/316

   ## Which issue does this PR close?
   
   None. It adds the test coverage that found #305–#315.
   
   ## Rationale for this change
   
   A Spark function can run in two ways. When every argument is a literal, the 
`simplify_expressions` optimizer rule constant-folds the call while planning. 
That calls `ScalarUDFImpl::simplify` (if the function has one) and evaluates 
the result on a one-row batch. Otherwise the call runs through 
`invoke_with_args` during execution. That is also the only path for engines 
such as Comet that build physical expressions directly.
   
   Most `.slt` queries are literal-only, such as `SELECT f(1)`, so today they 
only test the first path. `invoke_with_args` must always work, and `simplify` 
is an optional optimization. This PR runs the tests through both paths.
   
   ## What changes are included in this PR?
   
   - The runner runs every `.slt` file twice:
     - `simplify`: the default optimizer, as before.
     - `evaluate`: the same optimizer rules with `simplify_expressions` 
replaced by a rule that rewrites only DataFusion's rewrite-only functions 
(`arrow_cast`, `arrow_try_cast`, `cast_to_type`, `try_cast_to_type`, `nvl2`). 
The tests use those to build typed inputs, and their `invoke_with_args` always 
errors. Every other call, including literal-only calls of the Spark functions, 
runs through `invoke_with_args`.
   - Each run gets its mode as an `.slt` label, so a record can be marked 
`skipif evaluate`. (`skipif` rather than `onlyif simplify`, because the PySpark 
runner skips `onlyif` records that are not for `spark`.)
   - `--mode=simplify` or `--mode=evaluate` runs a single mode. Results print 
as `PASS [evaluate] path`.
   - A panic in one file is reported as that file failing, instead of aborting 
the whole run.
   - `EVALUATE_KNOWN_FAILURES` lists files that cannot pass in `evaluate` mode 
yet, each with its issue. A failure in a listed file prints `XFAIL` and does 
not fail the run. A listed file that passes does fail the run, so the entry 
gets removed when the issue is fixed.
   - `test_files/README.md` documents the two modes.
   
   ### What `evaluate` mode found
   
   Nine functions have no working `invoke_with_args`: they error unless 
`simplify` rewrites them first. Their files are in `EVALUATE_KNOWN_FAILURES`, 
except `unix.slt`, where only the `unix_date` queries are skipped.
   
   | Function | Issue |
   |---|---|
   | `if` | #305 |
   | `unix_date` | #306 |
   | `date_diff` | #307 |
   | `date_part` | #308 |
   | `date_trunc` | #309 |
   | `time_trunc` | #310 |
   | `trunc` | #311 |
   | `add_months` | #312 |
   | `base64` | #313 |
   
   Two bugs in the `invoke_with_args` path, each with one query marked `skipif 
evaluate`:
   
   - #314: `concat_ws` panics when all arguments are scalars and `number_rows` 
> 1. This is the same pattern #68 fixed in `hash`.
   - #315: `make_dt_interval` declares a non-nullable result but can return 
NULL.
   
   ## Are these changes tested?
   
   `cargo test -p datafusion-spark-sqllogictest` passes all 492 runs (246 files 
× 2 modes), with the 8 listed files reported as `XFAIL`. To check which files 
need the evaluate path, I temporarily ran each failing file record by record, 
so a file's first failure didn't hide the rest. Every evaluate-mode failure is 
one of the issues above. The PySpark runner still passes the three edited 
`.slt` files.
   
   ## Are there any user-facing changes?
   
   No. CI's sqllogictest job takes longer because every file now runs twice.
   
   🤖 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]

Reply via email to