One missing tag feed can null out Snowflake’s combined tag array
Keep the tags you received and report source coverage separately. An empty tag list and a missing feed are not the same thing.
Ask a SQL assistant to “show the tags we know about for each account,” and it might wrap the CRM and billing tag arrays in an outer array, then flatten it. In Snowflake, one missing input can make the entire result NULL, even if the other source supplied usable tags. Snowflake’s ARRAY_FLATTEN reference documents the rule: a NULL element in the outer array makes the function return NULL. An empty inner array, by contrast, contributes no elements to the concatenation.
Keep known tags and report completeness separately
Suppose the pipeline uses SQL NULL to mean that a feed did not deliver a tag list, and an empty array to mean that it delivered a list with no tags. In the synthetic example below, the CRM feed has renewal and the billing feed is missing. ARRAY_CONSTRUCT keeps the NULL input as an element; ARRAY_CONSTRUCT_COMPACT skips SQL NULL inputs. The example’s expected outputs follow from those documented rules.
WITH account AS (
SELECT ARRAY_CONSTRUCT('renewal') AS crm_tags,
NULL::ARRAY AS billing_tags
)
SELECT
ARRAY_FLATTEN(ARRAY_CONSTRUCT(crm_tags, billing_tags))
AS strict_tags,
ARRAY_FLATTEN(ARRAY_CONSTRUCT_COMPACT(crm_tags, billing_tags))
AS known_tags,
crm_tags IS NOT NULL AND billing_tags IS NOT NULL
AS both_sources_present
FROM account;
Here strict_tags is NULL, known_tags is ["renewal"], and both_sources_present is false. That lets a dashboard show a tag it actually received without implying that billing had no tags. If the question instead asks for a complete list from both feeds, use the strict result and display the coverage flag so readers know why it is missing.
Give generated SQL two nearly identical test rows
Hold the CRM array fixed at ["renewal"]. Give one row an empty billing array and the other a SQL NULL billing array. Both should show the same known tags, but only the first should report both sources present under this contract. Otherwise the query may have collapsed “checked and empty” into “not checked.” This pattern assumes each nonmissing input is itself an array: Snowflake documents that ARRAY_FLATTEN reports an error for a non-array element, and the compact constructor skips SQL NULLs, not arbitrary malformed values. It is a way to express a coverage policy, not a validator for incoming tags.
sources
- Snowflake ARRAY_FLATTEN referencedocs.snowflake.com
- Snowflake ARRAY_CONSTRUCT referencedocs.snowflake.com
- Snowflake ARRAY_CONSTRUCT_COMPACT referencedocs.snowflake.com
comments · 0
- EKOS’s pending BIRD submission pairs a SQLite-tuned run with a separate hidden-test scoreDec 3, 2026
- MotherDuck rolls out DuckDB 2.0 and reports faster cold reads, not faster agent answersDec 3, 2026
- Oracle Select AI can use two definitions of the same metric. Source order won’t break the tieDec 3, 2026