用量
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 資料欄為分割依據,以 city、age_tier 和 gender 資料欄為叢集依據,藉此最佳化根據這些資料欄篩選或匯總的查詢:
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 |