Skip to content

Commit

Permalink
Merge pull request #239 from Catisyf/main
Browse files Browse the repository at this point in the history
Add metadata_file_last_modified for snowpiped tables
  • Loading branch information
dataders authored Apr 10, 2024
2 parents a95bc05 + fa4f3b4 commit e5359d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions macros/plugins/snowflake/snowpipe/create_empty_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
{% endif %}
metadata_filename varchar,
metadata_file_row_number bigint,
metadata_file_last_modified timestamp,
_dbt_copied_at timestamp
);

Expand Down
9 changes: 5 additions & 4 deletions macros/plugins/snowflake/snowpipe/get_copy_sql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
{%- set external = source_node.external -%}
{%- set is_csv = dbt_external_tables.is_csv(external.file_format) %}
{%- set copy_options = external.snowpipe.get('copy_options', none) -%}

{%- if explicit_transaction -%} begin; {%- endif %}

copy into {{source(source_node.source_name, source_node.name)}}
from (
from (
select
{% if columns|length == 0 %}
$1::variant as value,
Expand All @@ -25,13 +25,14 @@
{% endif %}
metadata$filename::varchar as metadata_filename,
metadata$file_row_number::bigint as metadata_file_row_number,
metadata$file_last_modified::timestamp as metadata_file_last_modified,
current_timestamp::timestamp as _dbt_copied_at
from {{external.location}} {# stage #}
)
file_format = {{external.file_format}}
{% if external.pattern -%} pattern = '{{external.pattern}}' {%- endif %}
{% if copy_options %} {{copy_options}} {% endif %};

{% if explicit_transaction -%} commit; {%- endif -%}

{% endmacro %}

0 comments on commit e5359d8

Please sign in to comment.