Skip to content

Silence sqlglot warnings from internal sub-parser body re-rendering#625

Merged
macbre merged 2 commits into
macbre:masterfrom
collerek:fix/silence-subparser-warnings
May 7, 2026
Merged

Silence sqlglot warnings from internal sub-parser body re-rendering#625
macbre merged 2 commits into
macbre:masterfrom
collerek:fix/silence-subparser-warnings

Conversation

@collerek
Copy link
Copy Markdown
Collaborator

@collerek collerek commented May 7, 2026

Summary

  • NestedResolver._body_sql re-renders subquery bodies via sqlglot's generator and feeds the result to a sub-Parser. The generator defaulted to ErrorLevel.WARN, so unsupported-feature warnings (e.g. T-SQL FOR XML PATH) leaked to end users even though the regenerated SQL is internal-only.
  • Switched the internal generator to ErrorLevel.IGNORE — mirrors the existing parse-side silencing in DialectParser._parse_with_dialect.
  • Added a regression test using the issue Square brackets around SQL SERVER column outside of subquery faile #261 query that asserts the sqlglot logger emits no warnings during Parser(...).columns.

Resolves #261.

Test plan

  • poetry run pytest -vv --cov=sql_metadata --cov-report=term-missing — 267 passed, 100% coverage
  • poetry run mypy sql_metadata — clean
  • poetry run ruff check sql_metadata — clean
  • New test fails on master without the fix and passes with it

🤖 Generated with Claude Code

NestedResolver._body_sql re-renders subquery bodies via sqlglot's
generator and feeds the result to a sub-Parser.  Because the generator
defaulted to ErrorLevel.WARN, unsupported-feature warnings (e.g. T-SQL
FOR XML PATH) leaked to end users even though the regenerated SQL is
purely internal.  Switch to ErrorLevel.IGNORE — same rationale as the
existing parse-side silencing in DialectParser._parse_with_dialect.

Resolves macbre#261.
@collerek collerek requested a review from macbre as a code owner May 7, 2026 20:17
@macbre macbre enabled auto-merge (squash) May 7, 2026 22:43
@macbre macbre merged commit 9af6df2 into macbre:master May 7, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Square brackets around SQL SERVER column outside of subquery faile

2 participants