用法
explore: explore_name {
symmetric_aggregates: yes
}
|
层次结构
symmetric_aggregates |
默认值
yes
接受
布尔值(yes 或 no)
|
定义
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 扇出的问题中详细介绍了此问题及其解决方法。
并非所有数据库方言都支持具有对称聚合的 median 和 percentile 度量类型
启用对称汇总后,如果联接涉及扇出,Looker 会自动将 percentile 和 median 这两种衡量类型转换为 percentile_distinct 和 median_distinct。并非所有支持对称汇总的数据库方言都支持 percentile_distinct 和 median_distinct 度量类型。您可以在衡量类型文档页面上查看数据库方言是否支持 percentile_distinct 和 median_distinct 衡量类型。
如果您收到类似于 SQL dialect doesn't support Symmetric Aggregates with percentiles, field ignored. 的错误,则表示您的数据库方言不支持 percentile_distinct 和 median_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 |