用法
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 参数设置该数量。
示例
返回最多 10 万个不同值的确切 count_distinct:
measure: unique_count {
type: count_distinct
approximate_threshold: 100000 # default value is 1000
sql: ${id} ;;
}