File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1014,19 +1014,25 @@ def union(
10141014 raise SQLMeshError (f"Invalid type '{ type_ } '. Expected 'ALL' or 'DISTINCT'." )
10151015
10161016 # Remaining args should be tables
1017- tables = args [arg_idx :]
1017+ tables = []
1018+ for table in args [arg_idx :]:
1019+ if isinstance (table , exp .Column ):
1020+ table = exp .table_ (table .this , db = table .args .get ("table" ), catalog = table .args .get ("db" ))
1021+ else :
1022+ table = exp .to_table (table , dialect = evaluator .dialect ) # type: ignore
1023+ tables .append (table )
10181024
10191025 columns = {
10201026 column
10211027 for column , _ in reduce (
10221028 lambda a , b : a & b , # type: ignore
1023- (evaluator .columns_to_types (table ).items () for table in tables ), # type: ignore
1029+ (evaluator .columns_to_types (table ).items () for table in tables ),
10241030 )
10251031 }
10261032
10271033 projections = [
10281034 exp .cast (column , type_ , dialect = evaluator .dialect ).as_ (column )
1029- for column , type_ in evaluator .columns_to_types (tables [0 ]).items () # type: ignore
1035+ for column , type_ in evaluator .columns_to_types (tables [0 ]).items ()
10301036 if column in columns
10311037 ]
10321038
You can’t perform that action at this time.
0 commit comments