以前、COUNT(DISTINCT(X)) の代わりに GROUP BY して COUNT(X) しようという記事を書きました。 BigQuery で COUNT(DISTINCT(X)) を使わない方が良い理由 が、今は時代が変わりました。BigQuery にいつの間にか、EXACT_COUNT_DISTINCT() 関数が追加されたのです! Returns the exact number of non-NULL, distinct values for the specified field. For better scalability and performance, use COUNT(DISTINCT field). さらに non-NULL な値だけを数えてくれるという嬉しい仕様です。 というわけで、前の記事と同じく実際に publicdata:samples.github

