Expected COUNT DISTINCT facts are assertions only.

highlighted = computed this step

Honest by construction

Expected COUNT DISTINCT facts are assertions only.

compiler is source of truth\text{compiler is source of truth}

Render checked groups

The guarded grouped count renders 3 groups after recomputation.

checked groups=3\text{checked groups}=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.

Honest by construction: input rowsidregionbuyer1eastann2eastann3eastNULL4eastbea5westcy6westcy7northNULL8northNULL group bucketskeysourceRowsrowCount[east][0, 1, 2, 3]4[west][4, 5]2[north][6, 7]2 distinct non-NULL value bucketskeydistinctValuesvalueSourcesnullSourceRowsduplicatesFoldedcountDistinct[east][ann, bea][{value:ann, sourceRows:[0, 1]}, {value:bea, sourceRows:[3]}][2]12[west][cy][{value:cy, sourceRows:[4, 5]}][]11[north][][][6, 7]00 COUNT DISTINCT output rowsregiondistinct_counteast2west1north0 COUNT DISTINCT factsfactvalueinputRowCount8groupCount3outputRowCount3valueColumnbuyernullSkipped3duplicateValuesFolded2allNullGroups1groupOrderfirst_seen_source_order

Try to tamper

Wrong expected facts, derived sidecars, duplicate columns, bools, floats, missing columns, and alias collisions fail closed.

tamper rejected\text{tamper rejected}

Summary

This book shows exact finite COUNT DISTINCT over one value column only.

scoped COUNT DISTINCT model\text{scoped COUNT DISTINCT model}