Commit 328ee1b
committed
Decorrelate subqueries before handing the plan to the analytics engine
PPL queries that contain EXISTS / IN / SOME / ANY subqueries (and the
`subsearch` shapes that lower to them) currently crash on the
analytics-engine route with:
IllegalStateException: Unrecognized filter operator [EXISTS / EXISTS]
The analytics-engine's OpenSearchFilterRule resolves every leaf
predicate through ScalarFunction.fromSqlOperatorWithFallback, which
doesn't (and shouldn't) cover RexSubQuery operators. The legacy engine
path doesn't hit this because Calcite's RelRunner.prepareStatement
internally runs SubQueryRemoveRule + decorrelation before physical
conversion — the analytics path skips that pipeline entirely.
Fix: run the three SubQueryToCorrelate rules followed by
RelDecorrelator.decorrelateQuery on the RelNode just before handing it
to QueryPlanExecutor.execute (and the same in explain()). Placed on
AnalyticsExecutionEngine specifically so the legacy plan flow stays
byte-for-byte unchanged.
After: 19 -> 13 failures on CalcitePPLExistsSubqueryIT. The
"Unrecognized filter operator" is gone from every test (0/19 of that
signature remain); the remaining 13 failures are AssertionError result
mismatches that point at downstream analytics-engine semantics for
LEFT_ANTI / bare-group-by Aggregate inside the decorrelated join, which
are unrelated to subquery removal and need separate work.
Signed-off-by: Jialiang Liang <jialianl@amazon.com>
Signed-off-by: Jialiang Liang <jiallian@amazon.com>1 parent c4cac2a commit 328ee1b
1 file changed
Lines changed: 36 additions & 2 deletions
Lines changed: 36 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
13 | 16 | | |
| 17 | + | |
14 | 18 | | |
15 | 19 | | |
| 20 | + | |
16 | 21 | | |
17 | 22 | | |
18 | 23 | | |
| |||
77 | 82 | | |
78 | 83 | | |
79 | 84 | | |
| 85 | + | |
80 | 86 | | |
81 | 87 | | |
82 | | - | |
| 88 | + | |
83 | 89 | | |
84 | 90 | | |
85 | 91 | | |
86 | 92 | | |
87 | 93 | | |
88 | | - | |
| 94 | + | |
89 | 95 | | |
90 | 96 | | |
91 | 97 | | |
| |||
109 | 115 | | |
110 | 116 | | |
111 | 117 | | |
| 118 | + | |
112 | 119 | | |
113 | 120 | | |
114 | 121 | | |
| |||
148 | 155 | | |
149 | 156 | | |
150 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
151 | 185 | | |
0 commit comments