distribution_style

用量

view: my_view {
  derived_table: {
    distribution_style: all
    ...
  }
}
階層
distribution_style

- 或 -

distribution_style
預設值
無

接受
發布樣式 (all 或 even)
特殊規則
distribution_style 僅支援特定方言

定義

distribution_style 可讓您指定如何將永久衍生資料表 (PDT) 或匯總表格的查詢,分配到資料庫中的節點。

如需支援 distribution_style 的方言清單,請參閱「distribution_style 支援的方言」一節。

distribution_style 參數僅適用於永久資料表,例如 PDT 和匯總表格。如果衍生資料表沒有持續性策略,則不支援 distribution_style。

此外,使用 create_process 或 sql_create 定義的衍生資料表不支援 distribution_style 參數。

最後,請勿同時使用 distribution_style 和 distribution。如要根據資料欄值將資料表的資料列分配到不同的 Redshift 節點,請使用 distribution。否則,請使用 distribution_style 選擇其他發布策略。

Redshift 提供四種分配樣式,詳情請參閱 Amazon Redshift 分配樣式說明文件:

  • ALL 分布:所有資料列都會完整複製到每個節點。您可以在 Looker 中使用 distribution_style: all 完成這類發布作業。
  • EVEN 分配:資料列會以 round robin 方式分配到不同節點。在 Looker 中,您可以使用 distribution_style: even 達成這類分配。
  • KEY 分布:根據特定資料欄中的不重複值,將資料列分布到不同節點。如要在 Looker 中完成這類發布作業,請使用 distribution 參數。
  • AUTO Distribution:Redshift 會根據資料表資料大小,指派最佳的分配樣式。Looker 不支援這種分布類型。

請參閱 Amazon Redshift 關於分配樣式的說明文件,選擇合適的分配策略。如未指定 distribution_style,也未使用 distribution 參數,Looker 預設會使用 all。

範例

建立 customer_order_facts 衍生資料表,並將分配樣式設為 all:

view: customer_order_facts {
  derived_table: {
    sql:
      SELECT
        customer_id,
        COUNT(*) AS lifetime_orders
      FROM
        order
      GROUP BY 1 ;;
    persist_for: "24 hours"
    distribution_style: all
  }
}

distribution_style 的方言支援

能否使用 distribution_style,取決於 Looker 連線使用的資料庫方言。在最新版 Looker 中,下列方言支援 distribution_style:

方言 是否支援?
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
ClickHouse 26+
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+
Dremio 26+ with Arrow Flight SQL
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
MongoSQL
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