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 衡量类型。您可以在衡量类型文档页面上查看您的数据库方言是否支持这些衡量类型。

如果您收到类似于 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.x - 0.17.x
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