Skip to content

Commit 48a91e7

Browse files
committed
support filter in dump table
1 parent 9573189 commit 48a91e7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

macros/commands/dump_table.sql

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% macro dump_table(model_unique_id, output_path, exclude_deprecated_columns=true, timestamp_column=none, since=none, days_back=7, dedup=false, until=none) %}
1+
{% macro dump_table(model_unique_id, output_path, exclude_deprecated_columns=true, timestamp_column=none, since=none, days_back=7, dedup=false, until=none, filter=none) %}
22
{% set node = graph.nodes.get(model_unique_id) %}
33
{% if not node %}
44
{% do print("Node '{}' does not exist.".format(model_unique_id)) %}
@@ -35,6 +35,13 @@
3535
where {{ elementary.edr_datediff(elementary.edr_cast_as_timestamp(timestamp_column), elementary.edr_current_timestamp(), 'day') }} < {{ days_back }}
3636
{% endif %}
3737
{% endif %}
38+
{% if filter %}
39+
{% if timestamp_column %}
40+
and {{ filter }}
41+
{% else %}
42+
where {{ filter }}
43+
{% endif %}
44+
{% endif %}
3845
{% endset %}
3946
{% set results = elementary.run_query(query) %}
4047
{% do results.to_csv(output_path) %}

0 commit comments

Comments
 (0)