用法
view: view_name {
measure: field_name {
approximate: yes
}
}
|
层次结构
approximate |
可能的字段类型
测量
接受
布尔值(yes 或 no)
|
定义
如需查看支持
approximate的方言列表,请参阅本页面上的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.x - 0.17.x | |
| Apache Druid 0.18+ | |
| Apache Hive 2.3+ | |
| Apache Hive 3.1.2+ | |
| Apache Spark 3+ | |
| ClickHouse | |
| ClickHouse 26+ | |
| 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+ | |
| Dremio 26+ with Arrow Flight SQL | |
| Exasol | |
| Google BigQuery Legacy SQL | |
| Google BigQuery Standard SQL | |
| Google Cloud AlloyDB for PostgreSQL | |
| 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 | |
| MongoSQL | |
| 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 |