Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jtcohen6 committed Jun 15, 2022
1 parent ccd65ea commit 4b5ec8a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions dbt/include/spark/macros/utils/any_value.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% macro spark__any_value(expression) -%}
{#-- return any value (non-deterministic) --#}
first({{ expression }})
{%- endmacro %}

{%- endmacro %}
8 changes: 4 additions & 4 deletions dbt/include/spark/macros/utils/listagg.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
{% endif %}

{% set collect_list %} collect_list({{ measure }}) {% endset %}

{% set limited %} slice({{ collect_list }}, 1, {{ limit_num }}) {% endset %}

{% set collected = limited if limit_num else collect_list %}

{% set final %} array_join({{ collected }}, {{ delimiter_text }}) {% endset %}

{% do return(final) %}

{%- endmacro %}
10 changes: 5 additions & 5 deletions dbt/include/spark/macros/utils/split_part.sql
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{% macro spark__split_part(string_text, delimiter_text, part_number) %}

{% set delimiter_expr %}

-- escape if starts with a special character
case when regexp_extract({{ delimiter_text }}, '([^A-Za-z0-9])(.*)', 1) != '_'
then concat('\\', {{ delimiter_text }})
else {{ delimiter_text }} end

{% endset %}

{% set split_part_expr %}

split(
{{ string_text }},
{{ delimiter_expr }}
)[({{ part_number - 1 }})]

{% endset %}

{{ return(split_part_expr) }}

{% endmacro %}

0 comments on commit 4b5ec8a

Please sign in to comment.