Skip to content

Commit

Permalink
Added space between import CTEs
Browse files Browse the repository at this point in the history
  • Loading branch information
graciegoheen committed Sep 30, 2022
1 parent f536083 commit 2ff64be
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
12 changes: 12 additions & 0 deletions integration_tests/tests/test_generate_model_import_ctes.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,70 +18,82 @@ with codegen_integration_tests__data_source_schema_codegen_integration_tests__da
-- CAUTION: It's best practice to use the ref or source function instead of a direct reference

),

data__a_relation as (

select * from {% raw %}{{ ref('data__a_relation') }}{% endraw %}

),

data__b_relation as (

select * from {% raw %}{{ ref("data__b_relation") }}{% endraw %}

),

development_codegen_integration_tests__data_source_schema_codegen_integration_tests__data_source_table as (

select * from development.codegen_integration_tests__data_source_schema.codegen_integration_tests__data_source_table
-- CAUTION: It's best practice to use the ref or source function instead of a direct reference

),

my_other_table_reference as (

select * from {% raw %}{{ var("my_other_table_reference", "table_d") }}{% endraw %}
-- CAUTION: It's best practice to use the ref or source function instead of a var

),

my_schema_raw_relation_5 as (

select * from 'my_schema'.'raw_relation_5'
-- CAUTION: It's best practice to use the ref or source function instead of a direct reference

),

my_table_reference as (

select * from {% raw %}{{ var("my_table_reference") }}{% endraw %}
-- CAUTION: It's best practice to use the ref or source function instead of a var

),

raw_relation_1 as (

select * from `raw_relation_1`
-- CAUTION: It's best practice to use the ref or source function instead of a direct reference

),

raw_relation_2 as (

select * from "raw_relation_2"
-- CAUTION: It's best practice to use the ref or source function instead of a direct reference

),

raw_relation_3 as (

select * from [raw_relation_3]
-- CAUTION: It's best practice to use the ref or source function instead of a direct reference

),

raw_relation_4 as (

select * from 'raw_relation_4'
-- CAUTION: It's best practice to use the ref or source function instead of a direct reference

),

source_codegen_integration_tests__data_source_table as (

select * from {% raw %}{{ source('codegen_integration_tests__data_source_schema', 'codegen_integration_tests__data_source_table') }}{% endraw %}
-- CAUTION: It's best practice to create staging layer for raw sources

),

-- I love this cte
my_first_cte as (
select
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,70 +19,82 @@ with codegen_integration_tests__data_source_schema_codegen_integration_tests__da
-- CAUTION: It's best practice to use the ref or source function instead of a direct reference

)

,data__a_relation as (

select * from {% raw %}{{ ref('data__a_relation') }}{% endraw %}

)

,data__b_relation as (

select * from {% raw %}{{ ref("data__b_relation") }}{% endraw %}

)

,development_codegen_integration_tests__data_source_schema_codegen_integration_tests__data_source_table as (

select * from development.codegen_integration_tests__data_source_schema.codegen_integration_tests__data_source_table
-- CAUTION: It's best practice to use the ref or source function instead of a direct reference

)

,my_other_table_reference as (

select * from {% raw %}{{ var("my_other_table_reference", "table_d") }}{% endraw %}
-- CAUTION: It's best practice to use the ref or source function instead of a var

)

,my_schema_raw_relation_5 as (

select * from 'my_schema'.'raw_relation_5'
-- CAUTION: It's best practice to use the ref or source function instead of a direct reference

)

,my_table_reference as (

select * from {% raw %}{{ var("my_table_reference") }}{% endraw %}
-- CAUTION: It's best practice to use the ref or source function instead of a var

)

,raw_relation_1 as (

select * from `raw_relation_1`
-- CAUTION: It's best practice to use the ref or source function instead of a direct reference

)

,raw_relation_2 as (

select * from "raw_relation_2"
-- CAUTION: It's best practice to use the ref or source function instead of a direct reference

)

,raw_relation_3 as (

select * from [raw_relation_3]
-- CAUTION: It's best practice to use the ref or source function instead of a direct reference

)

,raw_relation_4 as (

select * from 'raw_relation_4'
-- CAUTION: It's best practice to use the ref or source function instead of a direct reference

)

,source_codegen_integration_tests__data_source_table as (

select * from {% raw %}{{ source('codegen_integration_tests__data_source_schema', 'codegen_integration_tests__data_source_table') }}{% endraw %}
-- CAUTION: It's best practice to create staging layer for raw sources

)

-- I love this cte
,my_first_cte as (
select
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ with data__a_relation as (
select * from {% raw %}{{ ref('data__a_relation') }}{% endraw %}

),

model_without_import_ctes as (

select * from {% raw %}{{ ref('model_without_import_ctes') }}{% endraw %}

)

select *, 2 as col2
from model_without_import_ctes as m
left join (select 2 as col_a from data__a_relation) as a on a.col_a = m.id
Expand Down
1 change: 1 addition & 0 deletions macros/generate_model_import_ctes.sql
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
{%- endif %}

){%- if ((loop.last and does_raw_sql_contain_cte) or (not loop.last)) and not leading_commas -%},{%- endif %}

{% endfor -%}

{%- if does_raw_sql_contain_cte -%}
Expand Down

0 comments on commit 2ff64be

Please sign in to comment.