Metacenta

BI semantic layer · rule lookml-join-no-relationship

Looker joins with no declared relationship

A Metacenta review checks this under the rule A join declares its relationship. Everything below applies whether or not you ever commission one.

What this rule checks

This rule flags every join in an explore that does not declare relationship:. A refinement that adds it counts. Joins inherited from an explore that was not supplied cannot be seen, so they are not counted.

Why it matters

Looker assumes many_to_one when a join does not say. If the join is really one-to-many, Looker does not know the rows fan out. Measures from the base view can then be counted once per joined row.

How to fix it

Declare the relationship on every Looker join. Declare relationship: on each join as a decision rather than a default: many_to_one, one_to_many, one_to_one or many_to_many.

Before:

explore: orders {
  join: order_items {
    sql_on: ${orders.order_id} = ${order_items.order_id} ;;
  }
}

After:

explore: orders {
  join: order_items {
    relationship: one_to_many
    sql_on: ${orders.order_id} = ${order_items.order_id} ;;
  }
}

When it is fine to leave

Very little. Where many_to_one is genuinely right the default does no harm today, but nobody can tell a decision from an oversight. Write it down; it is one line.

What we need to check it

The .lkml files alone.