Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add metadata_file_last_modified for snowpiped tables #239

Merged
merged 3 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
dataders marked this conversation as resolved.
Show resolved Hide resolved
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 %}
Loading