Skip to content

fix(backend): backtick-quote hyphenated catalog names in SQL queries - #123

Open
kir445 wants to merge 2 commits into
databrickslabs:masterfrom
kir445:fix/backend-backtick-hyphenated-catalogs
Open

fix(backend): backtick-quote hyphenated catalog names in SQL queries#123
kir445 wants to merge 2 commits into
databrickslabs:masterfrom
kir445:fix/backend-backtick-hyphenated-catalogs

Conversation

@kir445

@kir445 kir445 commented Jul 27, 2026

Copy link
Copy Markdown

Problem

Databricks SQL requires identifiers containing hyphens to be backtick-quoted. When a Unity Catalog name contains hyphens (e.g., arc-dbx-uc-cdp), SQL queries like SHOW SCHEMAS IN arc-dbx-uc-cdp fail with parse errors because the engine interprets the hyphens as minus operators.

Solution

Two complementary fixes:

SQLWarehouse.py

  • Added _quote_hyphenated_uc_identifiers() static method that automatically detects and backtick-quotes hyphenated identifiers in SQL
  • It only modifies SQL outside string literals ('...', "...") and already-backticked identifiers, so existing queries are not broken
  • Applied to all three execution entry points: query(), query_chunked(), and execute()

UnityCatalog.py

  • Wrapped {catalog} with backticks in all 5 SQL f-strings:
    • SHOW SCHEMAS IN
    • SHOW TABLES IN
    • DESCRIBE
    • SELECT ... FROM information_schema.tables
    • SHOW VOLUMES IN

Example

-- Before (fails)
SHOW SCHEMAS IN arc-dbx-uc-cdp

-- After (works)
SHOW SCHEMAS IN `arc-dbx-uc-cdp`


Closes #124 

@kir445
kir445 requested a review from a team as a code owner July 27, 2026 18:46
@CLAassistant

CLAassistant commented Jul 27, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@kir445
kir445 force-pushed the fix/backend-backtick-hyphenated-catalogs branch from 90b3927 to ba5c502 Compare July 27, 2026 19:12
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.

2 participants