Skip to content

Commit

Permalink
Merge pull request dbt-labs#100 from fishtown-analytics/feature/lengt…
Browse files Browse the repository at this point in the history
…h-macro

Feature: length macro
  • Loading branch information
axelazaid authored Dec 19, 2018
2 parents 04195db + c73adc5 commit bd8be6d
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
5 changes: 5 additions & 0 deletions integration_tests/data/cross_db/data_length.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
expression,output
abcdef,6
fishtown,8
december,8
www.google.com/path,19
6 changes: 6 additions & 0 deletions integration_tests/models/cross_db_utils/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ models:
- assert_equal:
actual: actual
expected: expected

- name: test_length
tests:
- assert_equal:
actual: actual
expected: expected

- name: test_safe_cast
tests:
Expand Down
12 changes: 12 additions & 0 deletions integration_tests/models/cross_db_utils/test_length.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
with data as (

select * from {{ ref('data_length') }}

)

select

{{ dbt_utils.length('expression') }} as actual,
output as expected

from data
21 changes: 21 additions & 0 deletions macros/cross_db_utils/length.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{% macro length(expression) -%}
{{ adapter_macro('dbt_utils.length', expression) }}
{% endmacro %}


{% macro default__length(expression) %}

length(
{{ expression }}
)

{%- endmacro -%}


{% macro redshift__length(expression) %}

len(
{{ expression }}
)

{%- endmacro -%}

0 comments on commit bd8be6d

Please sign in to comment.