User Guide Getting Started Help Center Documentation Community Training
New LookML
Old LookML
New LookML
Looker
  
English
Français
Deutsch
日本語
distribution

Usage

view: my_view {
  derived_table: {
    distribution: "customer_id"
    
  }
}

Hierarchy

distribution

Default Value

None

Accepts

The name of a column in a derived table

Definition

distribution lets you specify the column from a persistent derived table on which to apply a distribution key. Currently, distribution only works with Redshift and Aster databases. Traditional SQL dialects (such as MySQL and Postgres) should use indexes.

Generally speaking, a distribution key should be applied to the column that will be acting as a foreign key (i.e., the column you’ll use to join your derived table to others). More information can be found in the Redshift documentation and Aster documentation.

Examples

Create a customer_order_facts persistent native derived table (NDT) with a distribution key on customer_id:

view: customer_order_facts { derived_table: { explore_source: order { column: customer_id { field: order.customer_id } column: lifetime_orders { field: order.lifetime_orders } } datagroup_trigger: order_datagroup distribution: "customer_id" } }

Create a customer_order_facts derived table based on a SQL query with a distribution key on customer_id:

view: customer_order_facts { derived_table: { sql: SELECT customer_id, COUNT(*) AS lifetime_orders FROM order ;; persist_for: "24 hours" distribution: "customer_id" } }

Common Challenges

distribution Only Works with Derived Tables That Are Persisted

Derived tables can be calculated at query time, or they can be made persistent using datagroup_trigger, persist_for or sql_trigger_value. The distribution parameter works only with persistent derived tables.

Top