11from __future__ import annotations
22
33import typing as t
4+ import logging
45
56from sqlglot import exp , parse_one
67from sqlglot .helper import ensure_list
910from sqlmesh .utils .conversions import ensure_bool
1011from sqlmesh .utils .pydantic import field_validator
1112
13+ logger = logging .getLogger (__name__ )
14+
1215
1316def yaml_to_columns (
1417 yaml : t .Dict [str , ColumnConfig ] | t .List [t .Dict [str , ColumnConfig ]],
@@ -31,11 +34,20 @@ def column_types_to_sqlmesh(
3134 Returns:
3235 A dict of column name to exp.DataType
3336 """
34- return {
35- name : parse_one (column .data_type , into = exp .DataType , dialect = dialect or "" )
36- for name , column in columns .items ()
37- if column .enabled and column .data_type
38- }
37+ col_types_to_sqlmesh : t .Dict [str , exp .DataType ] = {}
38+ for name , column in columns .items ():
39+ if column .enabled and column .data_type :
40+ column_def = parse_one (
41+ f"{ name } { column .data_type } " , into = exp .ColumnDef , dialect = dialect or ""
42+ )
43+ if column_def .args .get ("constraints" ):
44+ logger .warning (
45+ f"Ignoring unsupported constraints for column '{ name } ' with definition '{ column .data_type } '."
46+ )
47+ kind = column_def .kind
48+ if kind :
49+ col_types_to_sqlmesh [name ] = kind
50+ return col_types_to_sqlmesh
3951
4052
4153def column_descriptions_to_sqlmesh (columns : t .Dict [str , ColumnConfig ]) -> t .Dict [str , str ]:
0 commit comments