用量
视图:view_name {
measure: field_name {
approximate_threshold: 100000
}
}
measure: field_name {
approximate_threshold: 100000
}
}
层次结构
approximate_threshold |
可能的字段类型
衡量接受
整数 |
定义
如果唯一值少于 1,000 个,Google BigQuery 旧版 SQL 会计算精确的 count_distinct
,但会针对较大数量的不同值执行近似计算。虽然统计速度较快,但通常有百分之几的误差。
如果您希望 BigQuery 旧版 SQL 针对超过 1000 个不同的值计算确切的 count_distinct
,则可以使用 approximate_threshold
参数来设置该金额。
示例
针对最多 10 万个不同的值返回确切的 count_distinct
:
measure: unique_count {
type: count_distinct
approximate_threshold: 100000 # default value is 1000
sql: ${id} ;;
}