diff --git a/dbt_project.yml b/dbt_project.yml index 71dd5fb7..3cf4cc16 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -81,5 +81,4 @@ vars: # -- Execution variables -- insert_batch_size: "{{ 500 if target.type == 'bigquery' else 10000 }}" - generate_all_dag_paths: true - max_depth_dag: 9 + max_depth_dag: infinite diff --git a/integration_tests_2/dbt_project.yml b/integration_tests_2/dbt_project.yml index 815295bf..21e7b3d6 100644 --- a/integration_tests_2/dbt_project.yml +++ b/integration_tests_2/dbt_project.yml @@ -36,5 +36,5 @@ models: +materialized: ephemeral vars: - generate_all_dag_paths: false - max_depth_dag: 5 \ No newline at end of file + max_depth_dag: 2 + chained_views_threshold: 2 \ No newline at end of file diff --git a/macros/recursive_dag.sql b/macros/recursive_dag.sql index 3d5d05b7..8948a2eb 100644 --- a/macros/recursive_dag.sql +++ b/macros/recursive_dag.sql @@ -101,10 +101,10 @@ all_relationships ( inner join all_relationships on all_relationships.child_id = direct_relationships.direct_parent_id - {% if not var('generate_all_dag_paths') %} + {% if var('max_depth_dag') != 'infinite' and var('max_depth_dag') is integer %} {% if var('max_depth_dag') < 2 or var('max_depth_dag') < var('chained_views_threshold')%} {% do exceptions.raise_compiler_error( - 'Variable max_depth_dag must be at least 2 and must be greater than chained_views_threshold.' + 'Variable max_depth_dag must be at least 2 and must be greater or equal to than chained_views_threshold.' ) %} {% else %} where distance <= {{ var('max_depth_dag')}} @@ -119,7 +119,12 @@ all_relationships ( {% macro bigquery__recursive_dag() %} -- as of Feb 2022 BigQuery doesn't support with recursive in the same way as other DWs -{% set max_depth = var('max_depth_dag') %} +{% set max_depth = var('max_depth_dag') if var('max_depth_dag') != 'infinite' and var('max_depth_dag') is integer else 9 %} +{% if max_depth < 2 or max_depth < var('chained_views_threshold') %} + {% do exceptions.raise_compiler_error( + 'Variable max_depth_dag must be at least 2 and must be greater or equal to than chained_views_threshold.' + ) %} +{% endif %} with direct_relationships as ( select