symmetric_aggregates

用量

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

接受
布林值 (yesno)

定義

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

根據預設,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 測量類型。如要查看資料庫方言是否支援 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 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