symmetric_aggregates

用量

explore: explore_name {
  symmetric_aggregates: yes
}
階層
symmetric_aggregates
預設值
yes

接受
布林值 (yesno)

定義

symmetric_aggregates 參數會決定是否要在指定的「探索」中套用對稱匯總。開啟 symmetric_aggregates 後,即使聯結導致扇出,匯總函式仍會傳回正確結果。如要進一步瞭解對稱匯總,請參閱「瞭解對稱匯總」最佳做法頁面,如要瞭解對稱匯總解決的扇出問題,請參閱這篇社群貼文

根據預設,Looker 中每個「探索」都會啟用對稱式匯總函式。也就是說,如果 SQL 方言支援對稱式匯總函式,只有在想為「探索」停用這項功能時,才需要加入 symmetric_aggregates 參數。

範例

為「product」探索啟用對稱式匯總函式:

explore: product {
  symmetric_aggregates: yes  # the default value, could be excluded
}

關閉「customer」探索的對稱式匯總函式:

explore: customer {
  symmetric_aggregates: no
}

注意事項

關閉對稱式匯總函式時,請謹慎建立聯結

當聯結導致擴散傳遞時,對稱式匯總函式可避免特定計算產生錯誤結果。因此,如果方言不支援對稱式匯總函式,或您選擇關閉這項功能,在 Looker 中執行聯結時就必須謹慎。如要詳細瞭解這個問題和解決方法,請參閱「SQL 擴散傳遞問題」這篇社群貼文。

並非所有資料庫方言都支援中位數和百分位數的對稱式匯總函式指標類型

啟用對稱式匯總函式時,如果彙整涉及擴散傳遞,Looker 會自動將 percentilemedian 測量指標類型轉換為 percentile_distinctmedian_distinct。並非所有支援對稱式匯總函式的資料庫方言都支援 percentile_distinctmedian_distinct 測量指標類型。如要查看資料庫方言是否支援這些測量指標類型,請參閱「測量指標類型」說明文件頁面。

如果收到類似 SQL dialect doesn't support Symmetric Aggregates with percentiles, field ignored. 的錯誤,表示資料庫方言不支援 percentile_distinctmedian_distinct 測量類型。如要解決這個問題,請將測量類型變更為 type: number,然後使用 sql: median(${dimension}) 指定匯總函式。不過,這樣會停用對稱式匯總函式。

支援對稱式匯總函式的方言

能否使用對稱式匯總函式取決於 Looker 連線使用的資料庫方言。在最新版 Looker 中,下列方言支援匯總感知:

方言 是否支援?
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 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
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