Snowflake ARRAY_POSITION can make a first-touch channel disappear from a funnel
A position of zero means the channel appeared first, not that it was missing. Test for NULL when the question is whether it appeared at all.
When an analyst asks how many customer journeys included email, a SQL assistant might look up the channel in each journey’s ordered array and count positions greater than zero. In Snowflake, that answers a different question: how many journeys first encountered email after the first touch. Snowflake’s ARRAY_POSITION reference says the index starts at zero and an absent value returns SQL NULL.
One fixture, three different counts
Take three illustrative sequences: ['email', 'search'], ['search', 'email'], and ['search', 'social']. Searching for 'email'::VARIANT in those semi-structured arrays gives positions 0, 1, and NULL, respectively, under the documented rules. A filter of position > 0 counts one journey. A filter of position IS NOT NULL counts two. A filter of position = 0 counts one, but it counts the other journey: the one where email was the first touch. This is a worked example, not a production measurement.
The danger is that the wrong answer still looks plausible. A dashboard can show a nonzero count even after silently dropping every journey that started with email. The example also catches a tempting rewrite: COALESCE(position, 0) gives both the first-touch journey and the no-email journey the same value. Once that distinction is lost, a later filter on the coalesced position alone cannot recover it.
Test the question, not just the query
For an analytics agent, make those three rows a regression test and ask three separate questions: “Did it appear anywhere?”, “Was it the first touch?”, and “Did it first appear after another touch?” Check which rows qualify, not just the counts: the last two answers are both one in this fixture. If a report needs a human-readable ordinal, preserve NULL for no match and add one to the returned index for display. And if the question is how often email appeared, this is the wrong function to answer it on its own: the reference specifies that ARRAY_POSITION returns only the first occurrence.
sources
- Snowflake SQL reference: ARRAY_POSITIONdocs.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