File tree Expand file tree Collapse file tree
sqlmesh/core/engine_adapter Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -411,3 +411,27 @@ def _build_column_defs(
411411 return super ()._build_column_defs (
412412 target_columns_to_types , column_descriptions , is_view , materialized
413413 )
414+
415+ def columns (
416+ self , table_name : TableName , include_pseudo_columns : bool = False
417+ ) -> t .Dict [str , exp .DataType ]:
418+ table = exp .to_table (table_name )
419+ query = (
420+ exp .select ("columns.column_name" , "columns.full_data_type" )
421+ .from_ ("system.information_schema.columns" )
422+ .where (
423+ exp .and_ (
424+ exp .column ("table_catalog" ).eq (table .catalog ),
425+ exp .column ("table_schema" ).eq (table .db ),
426+ exp .column ("table_name" ).eq (table .name ),
427+ )
428+ )
429+ .order_by ("ordinal_position ASC" )
430+ )
431+
432+ result = self .cursor .fetchall (query )
433+
434+ return {
435+ row .column_name : exp .DataType .build (row .full_data_type , dialect = self .dialect )
436+ for row in result
437+ }
You can’t perform that action at this time.
0 commit comments