Skip to content

Update sqlglot to support 27.0.0 or later #4227

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ dependencies = ["databricks-sdk>=0.58.0,<0.59.0",
"databricks-labs-lsql>=0.16.0,<0.17.0",
"databricks-labs-blueprint>=0.11.0,<0.12.0",
"PyYAML>=6.0.0,<6.1.0",
"sqlglot>=26.7.0,<26.8.0",
"sqlglot>=26.7.0,<27.1.0",
"astroid>=3.3.0,<3.4.0"]

[project.optional-dependencies]
Expand Down
11 changes: 9 additions & 2 deletions src/databricks/labs/ucx/source_code/sql/sql_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from typing import TypeVar

from sqlglot import parse
from sqlglot.errors import SqlglotError
from sqlglot.expressions import Create, Delete, Drop, Expression, Select, Table, Update, Use
from sqlglot.errors import SqlglotError, UnsupportedError
from sqlglot.expressions import Create, Delete, Drop, Expression, Select, Table, Update, Use, Identifier

from databricks.labs.ucx.source_code.base import UsedTable, CurrentSessionState

Expand Down Expand Up @@ -54,6 +54,13 @@ def _collect_table_info(
if not src_schema:
logger.warning(f"Could not determine schema for table {table.name}")
return None
# Sqlglot handlers parameter markers by returning an Identifier as the name instead of a string.
# For example: {foo} -> Identifier(this=foo)
if isinstance(table.name, Identifier):
# TODO: Support these properly, for example by inferring the placeholder value from the outside context.
msg = f"Table placeholder detected, not yet supported: {{{table.name}}}"
logger.debug(msg)
raise UnsupportedError(msg)
return UsedTable(
catalog_name=catalog_name,
schema_name=src_schema,
Expand Down