Skip to content

Commit

Permalink
Merge pull request #252 from thomas-vl/feature/update-table-columns
Browse files Browse the repository at this point in the history
update external table columns
  • Loading branch information
dataders authored Apr 11, 2024
2 parents 58fc3ce + 2bd4a35 commit c7ae743
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions macros/common/stage_external_sources.sql
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@

{% endfor %}

{% set update_columns = dbt_external_tables.update_external_table_columns(node) %}
{{ update_columns }}

{% endfor %}

{% endmacro %}
7 changes: 7 additions & 0 deletions macros/common/update_external_table_columns.sql
Original file line number Diff line number Diff line change
@@ -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 %}
1 change: 0 additions & 1 deletion macros/plugins/bigquery/create_external_table.sql
Original file line number Diff line number Diff line change
@@ -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 -%}
Expand Down
5 changes: 5 additions & 0 deletions macros/plugins/bigquery/update_external_table_columns.sql
Original file line number Diff line number Diff line change
@@ -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 %}

0 comments on commit c7ae743

Please sign in to comment.