Skip to content

Commit

Permalink
Merge pull request #42 from smart-on-fhir/mikix/quote-end
Browse files Browse the repository at this point in the history
fix(q_date_recent): quote "end" for Athena
  • Loading branch information
mikix authored May 30, 2024
2 parents f2ac356 + 38146d6 commit d75dc8b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cumulus_library_data_metrics/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Data Metrics study for Cumulus Library"""

__version__ = "2.0.0"
__version__ = "2.0.1"
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SELECT
src.id,

{% for field in fields %}
src.{{ field }} AS {{ field|replace('.', '_')|lower }},
src.{{ utils.quote_field(field) }} AS {{ field|replace('.', '_')|lower }},
{% endfor %}

src_status.status
Expand All @@ -33,7 +33,7 @@ WHERE
FALSE
{% for field in fields %}
OR (
{{ field }} IS NOT NULL
{{ utils.quote_field(field) }} IS NOT NULL
AND {{ utils.coalesce_date([field]) }} NOT BETWEEN DATE('1900-01-01') AND CURRENT_DATE
)
{% endfor %}
Expand Down
6 changes: 6 additions & 0 deletions cumulus_library_data_metrics/utils.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@
{%- endmacro %}


-- Quotes a field that may include keywords and periods (like src.end -> "src"."end")
{% macro quote_field(field) -%}
"{{ field|replace('.', '"."') }}"
{%- endmacro %}


-- Extracts a date field from a list of choices and returns a DATE.
{% macro coalesce_date(fields) -%}
date(from_iso8601_timestamp(
Expand Down

0 comments on commit d75dc8b

Please sign in to comment.