用法
view: view_name {
measure: field_name {
approximate: yes
}
}
|
层次结构
approximate |
可能的字段类型
测量
接受
布尔值(“是”或“否”)
|
定义
如需查看支持
indexes的方言列表,请参阅本页面的approximate的方言支持部分。
借助 approximate 参数,您可以将近似计数与 type: count 和 type: count_distinct 指标搭配使用。对于大型数据集,近似计数比精确计数快得多,并且通常与实际值的误差在几个百分点以内。请查看您的 SQL 方言的文档,了解此方法在速度和准确性方面的权衡取舍。
measure: apx_unique_count {
type: count_distinct
approximate: yes # default value is no
sql: ${id} ;;
}
-
启用 approximate 并将衡量标准设置为 type: count 似乎没有必要,因为近似计数功能仅适用于不同值的计数。不过,在某些情况下,Looker 会自动将 type: count 的度量转换为主键的去重计数,以便为联接视图提供准确的结果。在这些情况下,近似计数可能很有用。
针对 approximate 的方言支持
能否使用 approximate 取决于 Looker 连接所使用的数据库方言。在最新版 Looker 中,以下方言支持 approximate:
| 方言 | 是否支持? |
|---|---|
| Actian Avalanche | |
| Amazon Athena | |
| Amazon Aurora MySQL | |
| Amazon Redshift | |
| Amazon Redshift 2.1+ | |
| Amazon Redshift Serverless 2.1+ | |
| Apache Druid | |
| Apache Druid 0.13+ | |
| Apache Druid 0.18+ | |
| Apache Hive 2.3+ | |
| Apache Hive 3.1.2+ | |
| Apache Spark 3+ | |
| ClickHouse | |
| Cloudera Impala 3.1+ | |
| Cloudera Impala 3.1+ with Native Driver | |
| Cloudera Impala with Native Driver | |
| DataVirtuality | |
| Databricks | |
| Denodo 7 | |
| Denodo 8 & 9 | |
| Dremio | |
| Dremio 11+ | |
| Exasol | |
| Google BigQuery Legacy SQL | |
| Google BigQuery Standard SQL | |
| Google Cloud PostgreSQL | |
| Google Cloud SQL | |
| Google Spanner | |
| Greenplum | |
| HyperSQL | |
| IBM Netezza | |
| MariaDB | |
| Microsoft Azure PostgreSQL | |
| Microsoft Azure SQL Database | |
| Microsoft Azure Synapse Analytics | |
| Microsoft SQL Server 2008+ | |
| Microsoft SQL Server 2012+ | |
| Microsoft SQL Server 2016 | |
| Microsoft SQL Server 2017+ | |
| MongoBI | |
| MySQL | |
| MySQL 8.0.12+ | |
| Oracle | |
| Oracle ADWC | |
| PostgreSQL 9.5+ | |
| PostgreSQL pre-9.5 | |
| PrestoDB | |
| PrestoSQL | |
| SAP HANA | |
| SAP HANA 2+ | |
| SingleStore | |
| SingleStore 7+ | |
| Snowflake | |
| Teradata | |
| Trino | |
| Vector | |
| Vertica |