From a54884b4b6d7fa72b2a5baf63cdd9d227b5d9df6 Mon Sep 17 00:00:00 2001 From: Bjarke Enkelund <47357343+MisterWheatley@users.noreply.github.com> Date: Fri, 1 May 2026 08:00:46 +0000 Subject: [PATCH] Updated databricks adapter to use information_schema to get data-types for columns Signed-off-by: Bjarke Enkelund <47357343+MisterWheatley@users.noreply.github.com> --- sqlmesh/core/engine_adapter/databricks.py | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/sqlmesh/core/engine_adapter/databricks.py b/sqlmesh/core/engine_adapter/databricks.py index e3d029a17d..31745382e6 100644 --- a/sqlmesh/core/engine_adapter/databricks.py +++ b/sqlmesh/core/engine_adapter/databricks.py @@ -411,3 +411,27 @@ def _build_column_defs( return super()._build_column_defs( target_columns_to_types, column_descriptions, is_view, materialized ) + + def columns( + self, table_name: TableName, include_pseudo_columns: bool = False + ) -> t.Dict[str, exp.DataType]: + table = exp.to_table(table_name) + query = ( + exp.select("columns.column_name", "columns.full_data_type") + .from_("system.information_schema.columns") + .where( + exp.and_( + exp.column("table_catalog").eq(table.catalog), + exp.column("table_schema").eq(table.db), + exp.column("table_name").eq(table.name), + ) + ) + .order_by("ordinal_position ASC") + ) + + result = self.cursor.fetchall(query) + + return { + row.column_name: exp.DataType.build(row.full_data_type, dialect=self.dialect) + for row in result + }