NULL cells do not become counted buckets.

highlighted = computed this step

NULL is skipped

COUNT DISTINCT skips NULL cells in the counted column.

NULL skipped\text{NULL skipped}

Read skipped cells

The compiler skips 3 NULL buyer cells.

NULL skipped=3\text{NULL skipped}=3

COUNT DISTINCT examples are tiny finite-table transforms; SQL dialect completeness, collations, type coercion, optimizer behavior, execution cost, indexing, and database-product claims are out of scope.

NULL is skipped: input rowsidregionbuyer1eastann2eastann3eastNULL4eastbea5westcy6westcy7northNULL8northNULL group bucketskeysourceRowsrowCount[all_rows][0, 1, 2, 3, 4, 5, 6, 7]8 distinct non-NULL value bucketskeydistinctValuesvalueSourcesnullSourceRowsduplicatesFoldedcountDistinct[all_rows][ann, bea, cy][{value:ann, sourceRows:[0, 1]}, {value:bea, sourceRows:[3]}, {value:cy, sourceRows:[4, 5]}][2, 6, 7]23 COUNT DISTINCT output rowsdistinct_count3 COUNT DISTINCT factsfactvalueinputRowCount8groupCount1outputRowCount1valueColumnbuyernullSkipped3duplicateValuesFolded2allNullGroups0groupOrderfirst_seen_source_order

NULL is not a bucket

NULL cells are listed separately from distinct non-NULL value buckets.

NULL not counted\text{NULL not counted}

Summary

Skipping NULL happens before the distinct count.

skip then count\text{skip then count}