adriangb opened a new pull request, #27531:
URL: https://github.com/apache/datafusion/pull/27531

   ## Which issue does this PR close?
   
   - Closes https://github.com/apache/datafusion/issues/27485.
   
   ## Rationale for this change
   
   The SQL unparser has only hand-written tests. Gaps show up when a user 
unparses a real plan and the SQL does not plan again (for example 
https://github.com/apache/datafusion/issues/27477). The sqllogictest suite has 
thousands of checked queries, but none of them go through the unparser.
   
   ## What changes are included in this PR?
   
   A new runner flag, `--unparser-round-trip`, modeled on 
`--substrait-round-trip`:
   
   ```
   SQL -> logical plan -> plan_to_sql -> SQL -> logical plan -> execute -> 
compare rows
   ```
   
   - `--unparser-optimize` optimizes the plan before the engine unparses it.
   - `Ddl`, `Dml`, `Copy`, `Explain`, `Show` and `Statement` plans run 
unchanged.
   - The engine plans with `SessionState::create_logical_plan`. 
`SessionContext::sql` runs DDL eagerly and returns an empty plan, which 
unparses to an invalid `SELECT *`.
   - The engine needs no Cargo feature. It works with `configMatrix`.
   - The README documents the mode and its three failure kinds (unparse error, 
re-plan error, different rows).
   
   The mode is opt-in and CI does not run it. Many files fail today. The most 
common failure in `select.slt` and `aggregate.slt` is `Unsupported operator: 
Values` for a top-level `VALUES` plan. A later PR can run it in CI with a 
shrinking list of known-failing files.
   
   ## What is the testing strategy for this PR?
   
   I ran the mode by hand on `select.slt`, `limit.slt` and `aggregate.slt`. DDL 
now passes through, and the failures are real unparser gaps. The default runner 
is unchanged.
   
   ```shell
   cargo test --test sqllogictests -- --unparser-round-trip select.slt
   ```
   
   ## Are there any user-facing changes?
   
   No. This is a new test-runner flag only.
   
   🤖 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