approximate_threshold

用量

view: view_name {
  measure: field_name {
    approximate_threshold: 100000
  }
}
階層
approximate_threshold
可能的欄位類型
評估

接受
整數

定義

如果相異值少於 1,000 個,Google BigQuery 舊版 SQL 會計算確切的 count_distinct,但如果相異值較多,則會執行近似值計算。概略計數的速度較快,但通常會有幾個百分比的誤差。

如要讓 BigQuery 舊版 SQL 計算超過 1,000 個相異值的確切 count_distinct,可以使用 approximate_threshold 參數設定該值。

範例

傳回最多 100,000 個相異值的確切 count_distinct

measure: unique_count {
  type: count_distinct
  approximate_threshold: 100000   # default value is 1000
  sql: ${id} ;;
}