cluster_keys

用法

view: view_name {
  derived_table: {
    cluster_keys: ["customer_city", "customer_state"]
    ...
  }
}
层次结构
cluster_keys

- 或 -

cluster_keys
默认值
None

接受
一个或多个聚类列名称

特殊规则
cluster_keys 仅在特定方言中受支持

定义

分区表进行聚簇会根据聚簇列中的值对分区中的数据进行排序,并将聚簇列整理为大小最为合适的存储块。聚簇可以提高按聚簇列进行过滤或聚合的查询的性能并降低其费用。

如需查看支持 cluster_keys 的方言列表,请参阅cluster_keys 的方言支持部分。

如需向永久性派生表 (PDT) 或汇总表添加聚簇列,请使用 cluster_keys 参数并提供您希望在数据库表中聚簇的列的名称。

示例

在 BigQuery 数据库中创建一个 customer_order_facts 原生派生表,该表按 date 列进行分区,并按 cityage_tiergender 列进行聚簇,以优化按这些列进行过滤或汇总的查询:

view: customer_order_facts {
  derived_table: {
    explore_source: order {
      column: customer_id { field: order.customer_id }
      column: date { field: order.order_time }
      column: city { field: users.city}
      column: age_tier { field: users.age_tier }
      column: gender { field: users.gender }
      derived_column: num_orders {
        sql: COUNT(order.customer_id) ;;
      }
    }
    partition_keys: [ "date" ]
    cluster_keys: [ "city", "age_tier", "gender" ]
    datagroup_trigger: daily_datagroup
  }
}

针对 cluster_keys 的方言支持

能否使用 cluster_keys 取决于 Looker 连接所使用的数据库方言。在最新版 Looker 中,以下方言支持 cluster_keys

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