<br />

## Usage

```
view: my_view {
  derived_table: {
    distribution_style: all
    ...
  }
}
```

|---|---|
| Hierarchy [View File](https://docs.cloud.google.com/looker/docs/reference/param-view.md.txt) [`view`](https://docs.cloud.google.com/looker/docs/reference/param-view-view.md.txt) [`derived_table`](https://docs.cloud.google.com/looker/docs/reference/param-view-derived-table.md.txt) `distribution_style` - or - [Model File](https://docs.cloud.google.com/looker/docs/reference/param-model.md.txt) [`explore`](https://docs.cloud.google.com/looker/docs/reference/param-explore-explore.md.txt) [`aggregate_table`](https://docs.cloud.google.com/looker/docs/reference/param-explore-aggregate-table.md.txt) [`materialization`](https://docs.cloud.google.com/looker/docs/reference/param-explore-aggregate-table.md.txt#materialization) `distribution_style` | Default Value None <br /> Accepts A distribution style (`all` or `even`) Special Rules `distribution_style` is supported only on [specific dialects](https://docs.cloud.google.com/looker/docs/reference/param-view-distribution-style.md.txt#dialect_support) |

## Definition

`distribution_style` lets you specify how the query for a [persistent derived table](https://docs.cloud.google.com/looker/docs/derived-tables.md.txt#persistent-derived-tables) (PDT) or an [aggregate table](https://docs.cloud.google.com/looker/docs/reference/param-explore-aggregate-table.md.txt) is distributed across the nodes in a database.
> See the [Dialect support for `distribution_style`](https://docs.cloud.google.com/looker/docs/reference/param-view-distribution-style.md.txt#dialect_support_for_distribution_style) section for the list of dialects that support `distribution_style`.


> The `distribution_style` parameter works only with tables that are [persistent](https://docs.cloud.google.com/looker/docs/derived-tables.md.txt#adding_persistence), such as PDTs and aggregate tables. `distribution_style` is not supported for [derived tables](https://docs.cloud.google.com/looker/docs/creating-ndts.md.txt) without a persistence strategy.
> In addition, the `distribution_style` parameter is not supported for derived tables that are defined using [`create_process`](https://docs.cloud.google.com/looker/docs/reference/param-view-create-process.md.txt) or [`sql_create`](https://docs.cloud.google.com/looker/docs/reference/param-view-sql-create.md.txt).
>
> Lastly, `distribution_style` and [`distribution`](https://docs.cloud.google.com/looker/docs/reference/param-view-distribution.md.txt) should not be used at the same time. If you want to distribute the rows of a table to different Redshift nodes based on a column value, use [`distribution`](https://docs.cloud.google.com/looker/docs/reference/param-view-distribution.md.txt). Otherwise, use `distribution_style` to choose a different distribution strategy.

Redshift offers four distribution styles, which are described in the [Amazon Redshift documentation on distribution styles](http://docs.aws.amazon.com/redshift/latest/dg/c_choosing_dist_sort.html):

- **ALL Distribution:** All rows are fully copied to each node. You can accomplish this type of distribution in Looker by using `distribution_style: all`.
- **EVEN Distribution:** Rows are distributed to different nodes in a round-robin fashion. You can accomplish this type of distribution in Looker by using `distribution_style: even`.
- **KEY Distribution:** Rows are distributed to different nodes based on unique values within a particular column. You can accomplish this type of distribution in Looker by using the [`distribution`](https://docs.cloud.google.com/looker/docs/reference/param-view-distribution.md.txt) parameter.
- **AUTO Distribution** Redshift assigns an optimal distribution style based on the size of the table data. Looker does not support this distribution type.

See the [Amazon Redshift documentation on distribution styles](http://docs.aws.amazon.com/redshift/latest/dg/c_choosing_dist_sort.html) for choosing the appropriate distribution strategy. If you don't specify a `distribution_style`, and don't use the [`distribution`](https://docs.cloud.google.com/looker/docs/reference/param-view-distribution.md.txt) parameter instead, Looker will default to `all`.

## Examples

Create a `customer_order_facts` derived table with a distribution style of `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
      }
    }

## Dialect support for `distribution_style`

The ability to use `distribution_style` depends on the database dialect your Looker connection is using. In the latest release of Looker, the following dialects support `distribution_style`:

| Dialect | Supported? |
|---|---|
| Actian Avalanche | No |
| Amazon Athena | No |
| Amazon Aurora MySQL | No |
| Amazon Redshift | Yes |
| Amazon Redshift 2.1+ | Yes |
| Amazon Redshift Serverless 2.1+ | Yes |
| Apache Druid | No |
| Apache Druid 0.13.x - 0.17.x | No |
| Apache Druid 0.18+ | No |
| Apache Hive 2.3+ | No |
| Apache Hive 3.1.2+ | No |
| Apache Spark 3+ | No |
| ClickHouse | No |
| ClickHouse 26+ | No |
| Cloudera Impala 3.1+ | No |
| Cloudera Impala 3.1+ with Native Driver | No |
| Cloudera Impala with Native Driver | No |
| DataVirtuality | No |
| Databricks | No |
| Denodo 7 | No |
| Denodo 8 \& 9 | No |
| Dremio | No |
| Dremio 11+ | No |
| Dremio 26+ with Arrow Flight SQL | No |
| Exasol | No |
| Google BigQuery Legacy SQL | No |
| Google BigQuery Standard SQL | No |
| Google Cloud AlloyDB for PostgreSQL | No |
| Google Cloud PostgreSQL | No |
| Google Cloud SQL | No |
| Google Spanner | No |
| Greenplum | No |
| HyperSQL | No |
| IBM Netezza | No |
| MariaDB | No |
| Microsoft Azure PostgreSQL | No |
| Microsoft Azure SQL Database | No |
| Microsoft Azure Synapse Analytics | No |
| Microsoft SQL Server 2008+ | No |
| Microsoft SQL Server 2012+ | No |
| Microsoft SQL Server 2016 | No |
| Microsoft SQL Server 2017+ | No |
| MongoBI | No |
| MongoSQL | No |
| MySQL | No |
| MySQL 8.0.12+ | No |
| Oracle | No |
| Oracle ADWC | No |
| PostgreSQL 9.5+ | No |
| PostgreSQL pre-9.5 | No |
| PrestoDB | No |
| PrestoSQL | No |
| SAP HANA | No |
| SAP HANA 2+ | No |
| SingleStore | No |
| SingleStore 7+ | No |
| Snowflake | No |
| Teradata | No |
| Trino | No |
| Vector | No |
| Vertica | No |