Ro’s Looker Code Generation System: LookML Generation for Dimension Time Groups

John Mastro
Feb 20 · 2 min read

(article #2 in series)

For background on our Ro Looker Code Generation System, please see our intro article.

TL;DR

Background

For example, given a dimension_group like:

view: orders {
  # ...
    dimension_group: date_fulfilled {
      group_label: "WHEN"
      type: time
      datatype: datetime
      sql: ${TABLE}.created_at ;;
      timeframes: [
        date,
        day_of_month,
        day_of_week,
        hour,
        month,
        quarter,
        week,
        year
      ]
  }
}

Looker will create a dimension for each timeframe, and each of those dimensions will be available for use both within the LookML and in the resulting view. This is how they’re displayed in the Looker UI:

Our approach

So, we decided to simplify things a bit in our LookML-generation system. We define three levels of detail: “low”, “medium”, and “high”. Any dimension with type: time automatically gets the “medium” timeframes, and we can opt up or down by specifying timeframes: high or timeframes: low respectively.

Why not use “high” all the time? Having dimensions that won’t be used makes it harder for analysts and other business users to find the dimensions they want, and there can be a performance cost to having too many dimensions (and associated DOM nodes) in the Looker UI.

Summary

[1]: Is it dow or day_of_week? month_num, month_no, or month_of_year?

Ro Data Team Blog

Ro Data Team Blog: data analytics, data engineering, data science

John Mastro

Written by

Ro Data Team Blog

Ro Data Team Blog: data analytics, data engineering, data science