diff --git a/cumulus_library_data_metrics/us_core_v4/documentreference_mandatory.jinja b/cumulus_library_data_metrics/us_core_v4/documentreference_mandatory.jinja index 9034ebb..828f68f 100644 --- a/cumulus_library_data_metrics/us_core_v4/documentreference_mandatory.jinja +++ b/cumulus_library_data_metrics/us_core_v4/documentreference_mandatory.jinja @@ -13,7 +13,7 @@ tmp_attachment_flat AS ( {% if schema["content"]["attachment"] %} u.content.attachment.contenttype {% else %} - NULL AS contenttype + CAST(NULL AS VARCHAR) AS contenttype {% endif %} FROM {{ src }}, diff --git a/cumulus_library_data_metrics/us_core_v4/documentreference_must_support.jinja b/cumulus_library_data_metrics/us_core_v4/documentreference_must_support.jinja index ca69cda..cee9e76 100644 --- a/cumulus_library_data_metrics/us_core_v4/documentreference_must_support.jinja +++ b/cumulus_library_data_metrics/us_core_v4/documentreference_must_support.jinja @@ -7,16 +7,11 @@ WITH +{% if schema["content"]["format"] %} tmp_content_flat AS ( SELECT id, - - {% if schema["content"]["format"] %} u.content.format - {% else %} - NULL AS format - {% endif %} - FROM {{ src }}, UNNEST(content) AS u (content) ), @@ -27,6 +22,11 @@ tmp_content_grouped AS ( FROM tmp_content_flat GROUP BY id ), +{% else %} +tmp_content_grouped AS ( + SELECT id, FALSE AS valid_format FROM {{ src }} WHERE 1=0 -- return an empty table +), +{% endif %} tmp_encounters AS ( SELECT