diff --git a/integration_tests/models/plugins/bigquery/bigquery_external.yml b/integration_tests/models/plugins/bigquery/bigquery_external.yml index 3d6a0062..5cf76647 100644 --- a/integration_tests/models/plugins/bigquery/bigquery_external.yml +++ b/integration_tests/models/plugins/bigquery/bigquery_external.yml @@ -16,6 +16,7 @@ sources: columns: &cols-of-the-people - name: id data_type: int64 + description: id_of_the_person - name: first_name data_type: string - name: last_name diff --git a/macros/common/stage_external_sources.sql b/macros/common/stage_external_sources.sql index 7fad72d5..eaf55301 100644 --- a/macros/common/stage_external_sources.sql +++ b/macros/common/stage_external_sources.sql @@ -66,6 +66,9 @@ {% endfor %} + {% set update_columns = dbt_external_tables.update_external_table_columns(node) %} + {{ update_columns }} + {% endfor %} {% endmacro %} diff --git a/macros/common/update_external_table_columns.sql b/macros/common/update_external_table_columns.sql new file mode 100644 index 00000000..a37ec52f --- /dev/null +++ b/macros/common/update_external_table_columns.sql @@ -0,0 +1,7 @@ +{% macro update_external_table_columns(source_node) %} + {{ return(adapter.dispatch('update_external_table_columns', 'dbt_external_tables')(source_node)) }} +{% endmacro %} + +{% macro default__update_external_table_columns(source_node) %} + +{% endmacro %} diff --git a/macros/plugins/bigquery/create_external_table.sql b/macros/plugins/bigquery/create_external_table.sql index f578782a..fe7a5ac8 100644 --- a/macros/plugins/bigquery/create_external_table.sql +++ b/macros/plugins/bigquery/create_external_table.sql @@ -1,5 +1,4 @@ {% macro bigquery__create_external_table(source_node) %} - {%- set columns = source_node.columns.values() -%} {%- set external = source_node.external -%} {%- set partitions = external.partitions -%} diff --git a/macros/plugins/bigquery/update_external_table_columns.sql b/macros/plugins/bigquery/update_external_table_columns.sql new file mode 100644 index 00000000..5af562e9 --- /dev/null +++ b/macros/plugins/bigquery/update_external_table_columns.sql @@ -0,0 +1,5 @@ +{% macro bigquery__update_external_table_columns(source_node) %} + {%- set columns = source_node.columns -%} + {%- set relation = source(source_node.source_name, source_node.name) -%} + {%- do adapter.update_columns(relation, columns) -%} +{% endmacro %}