Skip to content

Commit

Permalink
adjust variable functionality and error message
Browse files Browse the repository at this point in the history
  • Loading branch information
dave-connors-3 committed Feb 17, 2023
1 parent fa28d14 commit 2d2134a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
3 changes: 1 addition & 2 deletions dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions integration_tests_2/dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ models:
+materialized: ephemeral

vars:
generate_all_dag_paths: false
max_depth_dag: 5
max_depth_dag: 2
chained_views_threshold: 2
11 changes: 8 additions & 3 deletions macros/recursive_dag.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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')}}
Expand All @@ -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
Expand Down

0 comments on commit 2d2134a

Please sign in to comment.