Commit 845a674
authored
fix(ol_dbt_cli): bound broken-column-macro collapse to prevent cross-CTE overrun (#2442)
* fix(ol_dbt_cli): bound broken-column-macro collapse to prevent cross-CTE overrun
sql_parser.py's Jinja-macro-tail collapse used an unbounded lazy loop to find
the next `) as alias` after a placeholder. A bare (unaliased) macro call
repeated in a GROUP BY list has no real terminal, so the search ran past the
GROUP BY, the CTE's closing paren, and the outer SELECT keyword before seizing
on an unrelated downstream alias -- corrupting the parsed SQL and producing
false yaml_sql_sync/broken_ref_columns errors on
marts__combined_program_enrollment_detail (which blocked this PR's CI after
rebasing onto the new dbt PR CI gate). Bound the continuation to 6 lines, which
still covers the two existing orphaned-tail regression tests, and make the
leading ')' before 'as' optional so a plain multi-line macro+alias (no stray
tokens) resolves on the very next line instead of searching further.
* fix(ol_dbt_cli): avoid invalid self-referential CTE in regression test
The new test's CTE was named 'combined' and its own body did 'from combined',
an invalid recursive self-reference without WITH RECURSIVE. Rename the CTE's
underlying source to raw_source so the test SQL is valid while still
exercising the same placeholder-collapsing behavior.1 parent a037100 commit 845a674
2 files changed
Lines changed: 52 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
200 | | - | |
201 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
202 | 212 | | |
203 | 213 | | |
204 | 214 | | |
205 | 215 | | |
206 | 216 | | |
207 | | - | |
208 | | - | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
209 | 223 | | |
210 | 224 | | |
211 | 225 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
273 | 307 | | |
274 | 308 | | |
275 | 309 | | |
| |||
0 commit comments