File tree Expand file tree Collapse file tree 1 file changed +20
-8
lines changed
sqlmesh/core/engine_adapter Expand file tree Collapse file tree 1 file changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -324,14 +324,26 @@ def create_mapping_schema(
324
324
bq_table = self ._get_table (table )
325
325
columns = create_mapping_schema (bq_table .schema )
326
326
327
- if (
328
- include_pseudo_columns
329
- and bq_table .time_partitioning
330
- and not bq_table .time_partitioning .field
331
- ):
332
- columns ["_PARTITIONTIME" ] = exp .DataType .build ("TIMESTAMP" , dialect = "bigquery" )
333
- if bq_table .time_partitioning .type_ == "DAY" :
334
- columns ["_PARTITIONDATE" ] = exp .DataType .build ("DATE" )
327
+ if include_pseudo_columns :
328
+ if bq_table .time_partitioning and not bq_table .time_partitioning .field :
329
+ columns ["_PARTITIONTIME" ] = exp .DataType .build ("TIMESTAMP" , dialect = "bigquery" )
330
+ if bq_table .time_partitioning .type_ == "DAY" :
331
+ columns ["_PARTITIONDATE" ] = exp .DataType .build ("DATE" )
332
+ if bq_table .table_id .endswith ("*" ):
333
+ columns ["_TABLE_SUFFIX" ] = exp .DataType .build ("STRING" , dialect = "bigquery" )
334
+ if (
335
+ bq_table .external_data_configuration is not None
336
+ and bq_table .external_data_configuration .source_format
337
+ in (
338
+ "CSV" ,
339
+ "NEWLINE_DELIMITED_JSON" ,
340
+ "AVRO" ,
341
+ "PARQUET" ,
342
+ "ORC" ,
343
+ "DATASTORE_BACKUP" ,
344
+ )
345
+ ):
346
+ columns ["_FILE_NAME" ] = exp .DataType .build ("STRING" , dialect = "bigquery" )
335
347
336
348
return columns
337
349
You can’t perform that action at this time.
0 commit comments