fix: Add Substrait roundtrip support for EXISTS and correlated OuterReferenceColumn #18987
+113
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Rationale for this change
Substrait roundtrip tests were failing for queries involving
EXISTSand correlated subqueries (specifically those using outer references). The DataFusion Substrait producer did not support serializingExpr::Exists, and it threw a "feature not implemented" error forOuterReferenceColumn.Supporting these features is essential for improving the reliability of DataFusion's Substrait integration and enabling complex join scenarios in distributed environments.
What changes are included in this PR?
Producer Support for
EXISTS:from_existsin the producer to mapExpr::Existsto the SubstraitSetPredicate(usingPredicateOp::Existence).NOT EXISTSby wrapping the predicate in a "not" scalar function.Producer Support for
OuterReferenceColumn:OuterReferenceColumnas a custom scalar function named"outer_reference". This avoids schema validation errors during serialization since outer columns often cannot be resolved against the local subquery schema.Consumer Support for
OuterReferenceColumn:"outer_reference"scalar function and deserialize it back into a DataFusionOuterReferenceColumn, ensuring a successful roundtrip.Are these changes tested?
Yes.
joins.slt.cargo test --test sqllogictests -- --substrait-round-trip joins.slt:1233Are there any user-facing changes?
No breaking API changes. This PR purely expands the coverage of supported Logical Plans that can be converted to/from Substrait.