Skip to content

Commit 2401dad

Browse files
committed
fix: Databricks column type identification by passing rendered SQL to execution cursor as opposed to AST.
Signed-off-by: davem-bis <68955845+davem-bis@users.noreply.github.com>
1 parent cb8acc5 commit 2401dad

2 files changed

Lines changed: 2 additions & 5 deletions

File tree

sqlmesh/core/engine_adapter/databricks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ def columns(
431431
.order_by("ordinal_position ASC")
432432
)
433433

434-
self.cursor.execute(query)
434+
self.cursor.execute(query.sql(dialect="databricks"))
435435
result = self.cursor.fetchall()
436436

437437
return {row[0]: exp.DataType.build(row[1], dialect=self.dialect) for row in result}

tests/core/engine_adapter/test_databricks.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -579,8 +579,5 @@ def test_columns(mocker: MockFixture, make_mocked_engine_adapter: t.Callable):
579579
}
580580

581581
adapter.cursor.execute.assert_called_once_with(
582-
parse_one(
583-
"""SELECT columns.column_name, columns.full_data_type FROM system.information_schema.columns WHERE table_name = 'test_table' AND table_schema = 'test_db' AND table_catalog = 'test_catalog' ORDER BY ordinal_position ASC""",
584-
dialect="databricks",
585-
)
582+
"""SELECT columns.column_name, columns.full_data_type FROM system.information_schema.columns WHERE table_name = 'test_table' AND table_schema = 'test_db' AND table_catalog = 'test_catalog' ORDER BY ordinal_position ASC"""
586583
)

0 commit comments

Comments
 (0)