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

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

示例

创建分布样式为 all 的 customer_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.x - 0.17.x
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
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