You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit f9b7f34
Browse filesBrowse the repository at this point in the historyBrowse files
## Which issue does this PR close?
- Closes#18066.
## Rationale for this change
Queries with conditionless joins can fail when their optimized logical
plans roundtrip through Substrait, with `Plan("join condition should not
be empty")`. This affects `LEFT JOIN ... ON true` and uncorrelated
`WHERE EXISTS`, as well as scalar-subquery projections when the legacy
scalar-subquery rewrite is enabled.
The optimizer can remove a constant `true` join filter. The producer
then omitted `JoinRel.expression`, which Substrait requires.
## What changes are included in this PR?
- Serialize conditionless inner joins as `CrossRel` and other
conditionless joins with a literal `true` condition.
- Handle overlapping input names when producing the synthetic condition
for semi, anti, and mark joins.
- Add SQL result coverage for outer joins and uncorrelated `EXISTS` /
`NOT EXISTS`, including empty inputs.
- Add an opt-in `--substrait-optimize` test mode and run the new fixture
through it in CI. This exercises the optimized plans that trigger the
bug.
## What is the testing strategy for this PR?
`joins_conditionless.slt` checks query results through ordinary SQL
execution and optimized Substrait roundtripping. Existing producer and
DataFrame tests cover conditionless inner joins, scalar-subquery
projections, and overlapping input names.
Local validation passed: formatting, Clippy with all targets and
features, the extended workspace suite, and `./dev/rust_lint.sh`. The
extended suite ran in an isolated PID namespace so the RSS tests could
sample a valid baseline on this host. Removing the producer fix makes
seven of the new optimized roundtrip cases fail with `join condition
should not be empty`; all pass with the fix restored.
## Are there any user-facing changes?
Queries containing conditionless joins can roundtrip through Substrait
successfully. No breaking production API changes.
---------
Co-authored-by: Bruno Volpato <[email protected]>
Copy file name to clipboardExpand all lines: .github/workflows/rust.yml
+4-2Lines changed: 4 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -700,10 +700,12 @@ jobs:
700
700
rust-version: stable
701
701
- name: Run sqllogictest
702
702
# TODO: Right now several tests are failing in Substrait round-trip mode, so this
703
-
# command cannot be run for all the .slt files. Run it for just one that works (limit.slt)
703
+
# command cannot be run for all the .slt files. Run a supported subset
704
704
# until most of the tickets in https://github.com/apache/datafusion/issues/16248 are addressed
705
705
# and this command can be run without filters.
706
-
run: cargo xtask ci step test substrait
706
+
run: |
707
+
cargo xtask ci step test substrait
708
+
cargo xtask ci step test substrait-optimized
707
709
708
710
# Temporarily commenting out the Windows flow, the reason is enormously slow running build
Copy file name to clipboardExpand all lines: datafusion/sqllogictest/README.md
+10-1Lines changed: 10 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -437,7 +437,8 @@ Not all statements will be round-tripped, some statements like CREATE, INSERT, S
437
437
issued as is, but any other statement will be round-tripped to/from Substrait.
438
438
439
439
_WARNING_: this mode lives behind the `substrait` feature, and the full suite still reports failures. CI therefore
440
-
runs it over a single file, through `cargo xtask ci step test substrait`, which filters to `limit.slt`. Some of the
440
+
runs `limit.slt` through `cargo xtask ci step test substrait` and optimized conditionless-join tests through
441
+
`cargo xtask ci step test substrait-optimized`. Some of the
441
442
failures are collected in https://github.com/apache/datafusion/issues/16248. To run the default suite in this mode:
442
443
443
444
```shell
@@ -450,6 +451,14 @@ For focusing on one specific failing test, a file:line filter can be used:
450
451
cargo test --test sqllogictests --features substrait -- --substrait-round-trip binary.slt:23
451
452
```
452
453
454
+
Add `--substrait-optimize` to optimize the logical plan before serialization. This exercises
455
+
producer inputs created by optimizer rewrites, such as conditionless joins from `LEFT JOIN ... ON true`
456
+
and uncorrelated `WHERE EXISTS`:
457
+
458
+
```shell
459
+
cargo test --test sqllogictests --features substrait -- --substrait-round-trip --substrait-optimize joins_conditionless.slt
460
+
```
461
+
453
462
## `.slt` file format
454
463
455
464
[`sqllogictest`] was originally written for SQLite to verify the
0 commit comments