diff --git a/macros/commands/dump_table.sql b/macros/commands/dump_table.sql index 0bd6c5d96..680588348 100644 --- a/macros/commands/dump_table.sql +++ b/macros/commands/dump_table.sql @@ -1,4 +1,4 @@ -{% macro dump_table(model_unique_id, output_path, exclude_deprecated_columns=true, timestamp_column=none, since=none, days_back=7, dedup=false, until=none) %} +{% macro dump_table(model_unique_id, output_path, exclude_deprecated_columns=true, timestamp_column=none, since=none, days_back=7, dedup=false, until=none, table_filter=none) %} {% set node = graph.nodes.get(model_unique_id) %} {% if not node %} {% do print("Node '{}' does not exist.".format(model_unique_id)) %} @@ -35,6 +35,13 @@ where {{ elementary.edr_datediff(elementary.edr_cast_as_timestamp(timestamp_column), elementary.edr_current_timestamp(), 'day') }} < {{ days_back }} {% endif %} {% endif %} + {% if table_filter %} + {% if timestamp_column %} + and {{ table_filter }} + {% else %} + where {{ table_filter }} + {% endif %} + {% endif %} {% endset %} {% set results = elementary.run_query(query) %} {% do results.to_csv(output_path) %}