Commit 8d2ee25
fix: address review feedback — avoid stale SPM and decouple spm capture from fetch
- Capture only the LexOrdering from the stripped SortPreservingMergeExec
instead of the entire plan node, then reconstruct a fresh SPM with the
current (possibly rewritten) child plan in the fallback path. This
avoids reusing a stale SPM that references an outdated subtree.
- Decouple spm_ordering capture from fetch — use `spm_ordering.is_none()`
instead of gating on `fetch.is_none()`, so the SPM ordering is recorded
even when an outer operator already set fetch.
- Remove unwrap() on with_fetch by constructing SPM directly.
- Fix test comment: fallback is CoalescePartitionsExec/SPM, not GlobalLimitExec.
- Add regression test: nested CoalescePartitionsExec(fetch=5) over
SortPreservingMergeExec(fetch=3) now correctly preserves SPM ordering.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 7785c33 commit 8d2ee25
2 files changed
Lines changed: 85 additions & 19 deletions
File tree
- datafusion
- core/tests/physical_optimizer
- physical-optimizer/src
Lines changed: 46 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3934 | 3934 | | |
3935 | 3935 | | |
3936 | 3936 | | |
3937 | | - | |
| 3937 | + | |
3938 | 3938 | | |
3939 | 3939 | | |
3940 | 3940 | | |
| |||
3994 | 3994 | | |
3995 | 3995 | | |
3996 | 3996 | | |
| 3997 | + | |
| 3998 | + | |
| 3999 | + | |
| 4000 | + | |
| 4001 | + | |
| 4002 | + | |
| 4003 | + | |
| 4004 | + | |
| 4005 | + | |
| 4006 | + | |
| 4007 | + | |
| 4008 | + | |
| 4009 | + | |
| 4010 | + | |
| 4011 | + | |
| 4012 | + | |
| 4013 | + | |
| 4014 | + | |
| 4015 | + | |
| 4016 | + | |
| 4017 | + | |
| 4018 | + | |
| 4019 | + | |
| 4020 | + | |
| 4021 | + | |
| 4022 | + | |
| 4023 | + | |
| 4024 | + | |
| 4025 | + | |
| 4026 | + | |
| 4027 | + | |
| 4028 | + | |
| 4029 | + | |
| 4030 | + | |
| 4031 | + | |
| 4032 | + | |
| 4033 | + | |
| 4034 | + | |
| 4035 | + | |
| 4036 | + | |
| 4037 | + | |
| 4038 | + | |
| 4039 | + | |
| 4040 | + | |
| 4041 | + | |
3997 | 4042 | | |
3998 | 4043 | | |
3999 | 4044 | | |
| |||
Lines changed: 39 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| |||
1023 | 1024 | | |
1024 | 1025 | | |
1025 | 1026 | | |
1026 | | - | |
| 1027 | + | |
1027 | 1028 | | |
1028 | 1029 | | |
1029 | | - | |
| 1030 | + | |
1030 | 1031 | | |
1031 | 1032 | | |
1032 | 1033 | | |
1033 | 1034 | | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
1034 | 1048 | | |
1035 | 1049 | | |
1036 | 1050 | | |
1037 | 1051 | | |
1038 | 1052 | | |
1039 | | - | |
1040 | | - | |
1041 | | - | |
1042 | 1053 | | |
1043 | 1054 | | |
1044 | 1055 | | |
| |||
1047 | 1058 | | |
1048 | 1059 | | |
1049 | 1060 | | |
1050 | | - | |
| 1061 | + | |
1051 | 1062 | | |
1052 | 1063 | | |
1053 | 1064 | | |
| |||
1250 | 1261 | | |
1251 | 1262 | | |
1252 | 1263 | | |
1253 | | - | |
| 1264 | + | |
1254 | 1265 | | |
1255 | 1266 | | |
1256 | 1267 | | |
| |||
1518 | 1529 | | |
1519 | 1530 | | |
1520 | 1531 | | |
1521 | | - | |
1522 | | - | |
1523 | | - | |
1524 | | - | |
1525 | | - | |
1526 | | - | |
1527 | | - | |
1528 | | - | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
1529 | 1543 | | |
1530 | | - | |
1531 | | - | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
1532 | 1553 | | |
1533 | 1554 | | |
1534 | 1555 | | |
| |||
0 commit comments