Commit a2a598b
fix: Set from_source in ExpressionLifter to fix QUALIFY regression
Fixes the QUALIFY clause regression introduced by the from_source migration.
The issue was that ExpressionLifter was only setting the deprecated from_table
field when creating CTEs, not the new from_source field. This caused the query
engine to not properly recognize CTE references.
Changes:
- Updated ExpressionLifter to set both from_source (preferred) and from_table (deprecated)
- Added logic in StatementExecutor to re-extract base table when preprocessing adds CTEs
- All 28 formal tests now passing (including qualify.sql)
- All 396 Rust unit tests passing
The ExpressionLifter creates CTEs like:
WITH __lifted_1 AS (SELECT *, ROW_NUMBER() ... AS rn FROM sales)
SELECT ... FROM __lifted_1
Now from_source is properly set to TableSource::Table("__lifted_1") so the
query engine can find the CTE in the cte_context and use it as the source table.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent bf857c4 commit a2a598b
2 files changed
Lines changed: 24 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
157 | 169 | | |
158 | 170 | | |
159 | | - | |
| 171 | + | |
| 172 | + | |
160 | 173 | | |
161 | 174 | | |
162 | 175 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
354 | 354 | | |
355 | 355 | | |
356 | 356 | | |
357 | | - | |
358 | | - | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
359 | 367 | | |
360 | 368 | | |
361 | 369 | | |
| |||
0 commit comments