用量
view: view_name {
measure: field_name {
approximate: yes
}
}
|
階層
approximate |
可能的欄位類型
度量
接受
布林值 (是或否)
|
定義
如需支援
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 |