Snowflake SPLIT_PART can group a missing campaign label with a blank one
A suffix that was never sent and one that was sent empty both become an empty string. Keep the delimiter check if they mean different things in your reporting.
Suppose a marketing export encodes a channel and an optional campaign label as channel|label. In this example, paid means the producer omitted the second field, while paid| means it sent the field but left it blank. In Snowflake, SPLIT_PART(raw_key, '|', 2) returns the same empty string for both. If an analytics agent groups by that expression alone, it cannot tell how many labels were omitted and how many were sent blank.
One result, two reasons
Snowflake’s SPLIT_PART reference says that requesting an out-of-range part returns an empty string. It also says that whitespace is not required to make an empty field: the space after a trailing delimiter is itself a valid, empty part. A SQL NULL input is different again; the function returns NULL rather than an empty string.
| Example input | Expected second part | Meaning in this export | |
|---|---|---|---|
paid | Empty string | Field missing | |
| `paid\ | ` | Empty string | Field present but blank |
| `paid\ | spring` | spring | Field present with a value |
SQL NULL | SQL NULL | Entire key missing |
These are expected results for a synthetic fixture, derived from the documented rules. The distinction is visible before extraction: Snowflake’s SPLIT reference specifies that a trailing separator produces an empty element in the returned array. Splitting paid gives one element; splitting paid| gives two.
Classify the input before grouping
For an export that allows at most one pipe and does not allow escaped delimiters, test for the separator before testing the extracted label:
CASE
WHEN raw_key IS NULL THEN 'key_missing'
WHEN raw_key NOT LIKE '%|%' THEN 'label_missing'
WHEN SPLIT_PART(raw_key, '|', 2) = '' THEN 'label_blank'
ELSE 'label_present'
END AS label_status
Count by label_status when investigating feed quality, and keep the extracted campaign label as a separate column for performance reporting. If the format permits quoted delimiters or extra fields, validate against that format rather than using the one-pipe check. For agent-generated SQL, put all four rows in an acceptance test and assert four distinct statuses if that is the business rule. If the reporting definition deliberately merges omitted and blank labels, document that decision instead of letting the parser make it silently.
sources
- Snowflake SQL reference: SPLIT_PARTdocs.snowflake.com
- Snowflake SQL reference: SPLITdocs.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