distribution_style

用法

view: my_view {
  derived_table: {
    distribution_style: all
    ...
  }
}
层次结构
distribution_style

- 或 -

distribution_style
默认值

接受
一种分布样式(alleven
特殊规则
distribution_style 仅在 特定方言 中支持

定义

distribution_style 借助 ,您可以指定如何将 永久性派生表 (PDT) 或 汇总表格 的查询分布到数据库中的各个节点。

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

distribution_style 参数仅适用于 永久 表,例如 PDT 和汇总表。不支持 distribution_style,因为 派生表 没有持久性策略。

此外,对于使用 create_processsql_create 定义的派生表,不支持 distribution_style 参数。

最后,distribution_styledistribution 不应同时使用。如果您想根据列值将表的行分布到不同的 Redshift 节点,请使用 distribution。否则,请使用 distribution_style 选择其他分布策略。

Redshift 提供四种分布样式,这些样式在 Amazon Redshift 文档中的分布样式中进行了说明:

  • ALL 分布 :所有行都会完整复制到每个节点。您可以在 Looker 中使用 distribution_style: all 实现这种类型的分布。
  • EVEN 分布 :行以轮循方式分布到不同的节点。您可以在 Looker 中使用 distribution_style: even 实现这种类型的分布。
  • KEY 分布 :行根据特定列中的唯一值分布到不同的节点。您可以在 Looker 中使用 distribution 参数实现这种类型的分布。
  • AUTO 分布 :Redshift 会根据表数据的大小分配最佳分布样式。Looker 不支持这种分布类型。

如需选择合适的分布策略,请参阅 Amazon Redshift 文档中的分布样式。如果您未指定 distribution_style,并且未使用 distribution 参数,Looker 将默认使用 all

示例

创建一个分布样式为 allcustomer_order_facts 派生表:

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+
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