I have a simple 9 column report that I'm sideloading into bigquery via the dbt-external-tables module.
version: 2
sources:
- name: my_schema
database: my_project
loader: gcloud storage
tables:
- name: my_table_raw
description: "external table of reports"
external:
location: 'gs://my_bucket/my_reports/*'
auto_refresh: false
options:
format: csv
skip_leading_rows: 1
Everything with this setup is fine so far, data imports correctly, queryable etc.
My simple addition: what is the simplest way to append the file name as a column?
I've attempted something to the effect of:
- name: file_name_column
expression: metadata$filename
data_type: string
description: "the source file name from within gcp"
But it looks like bigquery / the module is looking to match the number of columns on the table with the number of columns in the files because I am able to "create" the table in bigquery but get all kinds of errors when I query against it.
Update: from what I see here - the "metadata" expression that I've seen and am trying to use above is snowflake specific. Source link.