Skip to content

fix: SQL quality rule placeholders quoted per dialect, parse errors clearer (#1653) - #1660

Merged
jschoedl merged 3 commits into
mainfrom
fix-placeholder-quoting-1653
Sep 25, 2026
Merged

jschoedl merged 3 commits into
mainfrom
fix-placeholder-quoting-1653

Conversation

@jschoedl

@jschoedl jschoedl commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

SQL quality rule placeholders are now quoted in the server's dialect when a name needs it (e.g. a column with a space), and a query that doesn't parse reports the parse error instead of a generic refusal.

Fixes #1653

…learer (#1653)

- Backticks around a placeholder now force quoting in the server's dialect, so
  reserved words like {join} work on Spark/Databricks.
- Names with dialect-specific safe characters (e.g. $ on Snowflake) stay bare,
  matching behavior on main.
- Parse error messages show "Incomplete expression" instead of sqlglot internals.
- Single-pass placeholder substitution prevents double-substitution of nested
  placeholder-like text.
- New tests cover backtick quoting, safe-character names, and parse error detail.
@jschoedl
jschoedl marked this pull request as ready for review September 25, 2026 08:54
- Drop column numbers from parse-error messages (line + token is clearer; columns shift
  by placeholder-substitution length differences)
- Simplify generic 'not read-only' refusal message: remove dialect name since this path
  only fires for multi-statement or non-SELECT queries that already parse successfully
- Rename sqlglot_dialect() to sqlglot_dialect_by_name() to avoid collision with same name
  in native_type.py (calls from ibis_check_execute.py use the latter)
Use databricks instead of local server to test that amount$usd gets quoted. The
bare-name regex behaves differently across sqlglot versions (30.17 accepts $ in
DuckDB names, 28.10 doesn't), but Databricks's tokenizer has no extra name chars
in either version, so the assertion stays consistent. The Snowflake assertion
(which leaves the name bare) is unchanged.
@jschoedl
jschoedl merged commit 3067d38 into main Sep 25, 2026
19 checks passed
@jschoedl
jschoedl deleted the fix-placeholder-quoting-1653 branch September 25, 2026 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant