Skip to content

Commit

Permalink
Merge pull request #11 from matt-winkler/feature/sql-headers
Browse files Browse the repository at this point in the history
test udf
  • Loading branch information
matt-winkler authored Apr 5, 2021
2 parents b6f57f3 + 64e11ba commit 3c005e4
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 23 deletions.
23 changes: 0 additions & 23 deletions models/marts/core/fct_orders__incremental.sql

This file was deleted.

Empty file added models/marts/curate/curate.yml
Empty file.
5 changes: 5 additions & 0 deletions models/marts/curate/orders_aggregate.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{{
config(materialized='table')
}}

with orders as ( select * from {{ ref('order_items') }} ),

aggregated as (
Expand All @@ -8,4 +12,5 @@ aggregated as (
group by 1
)


select * from aggregated
26 changes: 26 additions & 0 deletions models/marts/curate/udf_test.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{{
config(materialized='table')
}}

{% call set_sql_header(config) %}

CREATE TEMPORARY FUNCTION yes_no_to_boolean(answer STRING)
RETURNS BOOLEAN AS (
CASE
WHEN LOWER(answer) = 'yes' THEN True
WHEN LOWER(answer) = 'no' THEN False
ELSE NULL
END
);

{% endcall %}

with bool_test as (

select 1 as Id, 'yes' as Answer UNION ALL
select 1 as Id, 'no' as Answer
)

-- select * from aggregated

select Id, yes_no_to_boolean(Answer) as Result from bool_test

0 comments on commit 3c005e4

Please sign in to comment.