Commit 7f96102
committed
feat(sql): implement subquery-to-join rewriting for IN/NOT IN
Replace the subquery.rs stub with a complete implementation that
rewrites WHERE-clause subqueries into semi/anti joins, allowing the
existing hash-join executor to handle them without a separate subquery
engine.
Supported patterns:
- `WHERE col IN (SELECT col2 FROM tbl)` → semi-join
- `WHERE col NOT IN (SELECT col2 FROM tbl)` → anti-join
- `WHERE col > (SELECT AGG(...) FROM tbl)` → materialized scalar subquery
Both select and join planners now call extract_subqueries() to strip
subquery predicates from the WHERE clause before filter conversion, then
wrap the base plan with the extracted join nodes. Semi and Anti join
operators are also wired into the join operator mapping.1 parent 809b662 commit 7f96102
3 files changed
Lines changed: 362 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
87 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
88 | 95 | | |
89 | | - | |
| 96 | + | |
90 | 97 | | |
91 | 98 | | |
92 | 99 | | |
93 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
94 | 113 | | |
95 | 114 | | |
96 | 115 | | |
| |||
124 | 143 | | |
125 | 144 | | |
126 | 145 | | |
127 | | - | |
| 146 | + | |
128 | 147 | | |
129 | 148 | | |
130 | 149 | | |
131 | | - | |
| 150 | + | |
132 | 151 | | |
133 | 152 | | |
134 | 153 | | |
135 | | - | |
| 154 | + | |
136 | 155 | | |
137 | 156 | | |
138 | 157 | | |
| |||
144 | 163 | | |
145 | 164 | | |
146 | 165 | | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
147 | 174 | | |
148 | 175 | | |
149 | 176 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
97 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
98 | 106 | | |
99 | 107 | | |
100 | 108 | | |
| |||
105 | 113 | | |
106 | 114 | | |
107 | 115 | | |
108 | | - | |
| 116 | + | |
109 | 117 | | |
110 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
111 | 132 | | |
112 | 133 | | |
113 | | - | |
| 134 | + | |
114 | 135 | | |
115 | 136 | | |
116 | | - | |
| 137 | + | |
117 | 138 | | |
118 | 139 | | |
119 | | - | |
120 | | - | |
| 140 | + | |
| 141 | + | |
121 | 142 | | |
122 | 143 | | |
123 | 144 | | |
| |||
127 | 148 | | |
128 | 149 | | |
129 | 150 | | |
130 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
131 | 166 | | |
132 | 167 | | |
133 | 168 | | |
| |||
0 commit comments