kosiew opened a new pull request, #18842:
URL: https://github.com/apache/datafusion/pull/18842
## Which issue does this PR close?
* Closes #16271.
## Rationale for this change
This change resolves a long‑standing gap in DataFusion’s Substrait
round‑trip implementation where `EmptyRelation` with `produce_one_row=true`
could not be encoded or decoded. This limitation caused ~1800 sqllogictest
cases to fail, particularly those involving queries without a FROM clause
(e.g., `SELECT 1`).
By adding full support for recognizing and producing the Substrait
VirtualTable pattern representing a “phantom row,” DataFusion can now
faithfully round‑trip logical plans that use empty relations to provide scalar
evaluation contexts. This unblocks broader Substrait compatibility and improves
consistency across logical plan conversions.
## What changes are included in this PR?
* Implement detection of the Substrait VirtualTable patterns representing
`produce_one_row` and map them to `LogicalPlan::EmptyRelation`.
* Add `from_empty_relation` encoding logic that emits a properly structured
VirtualTable, including default literal values when `produce_one_row=true`.
* Refactor literal row conversion into a helper (`convert_literal_rows`) for
clarity and reuse.
* Improve field‑count validation for expression‑based VirtualTables.
* Add comprehensive round‑trip test coverage:
* SELECT without FROM
* Mixed‑type EmptyRelation with phantom row
* EmptyRelation with zero rows
* Subqueries involving EmptyRelation
## Are these changes tested?
Yes. New integration tests exercise all permutations of EmptyRelation
encoding and decoding, including edge cases related to schema handling and
subqueries. These tests ensure round‑trip correctness and prevent regressions.
## Are there any user-facing changes?
No user‑facing API changes. This PR improves Substrait interoperability
internally.
## LLM-generated code disclosure
This PR includes LLM‑generated code and comments. All generated content has
been manually reviewed and tested.
--
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]