用量
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 |