Extending Explores to a Different Model


(Segah Mir@Caura & Co.) #1

A common problem that organizations have is providing all of the necessary data without drowning the user in irrelevant data. For example, consider the following situation:

The marketing team and finance team share a lot of the same data. However, the marketing team has lots of data that is irrelevant to the finance team. The finance team should be able to choose to view only the data relevant to them, without being overwhelmed with marketing-specific content.

LookML extends allows precisely this functionality.

Take these two models as an example:

  • finance
  • marketing

Our finance model might look as follows:

Old LookML ``` - connection: default_name
  • include: “*.view.lookml”
  • include: “*.dashboard.lookml”

this explore will not be accessible - it is just a template

  • explore: order_items
    view: order_items
    from: order_items
    extension: required
    joins:

    • join: orders
      type: left_outer
      sql_on: ${order_items.order_id} = ${orders.id}
      relationship: many_to_one
  • explore: order_items_finance
    extends: order_items

</details>
<details>
<summary>New LookML</summary>

connection: “default_name”

include: “.view.lkml"
include: "
.dashboard.lkml”

this explore will not be accessible - it is just a template

explore: order_items {
view_name: order_items
from: order_items
extension: required

join: orders {
type: left_outer
sql_on: ${order_items.order_id} = ${orders.id} ;;
relationship: many_to_one
}
}

explore: order_items_finance {
extends: [order_items]
}

</details>

While this is enough for the finance model, marketing actually needs more user-specific information to identify cohorts by referral source and age demographics.

For that we can extend the finance model:
<details>
<summary>Old LookML</summary>
  • connection: default_name

  • include: “finance.model.lookml”

  • explore: order_items_marketing
    extends: order_items
    joins:

    • join: users
      type: left_outer
      sql_on: ${orders.user_id} = ${users.id}
      relationship: many_to_one
</details>

<details>
<summary>New LookML</summary>

connection: “default_name”

include: “finance.model.lkml”

explore: order_items_marketing {
extends: [order_items]

join: users {
type: left_outer
sql_on: ${orders.user_id} = ${users.id} ;;
relationship: many_to_one
}
}

</details>


With this, there should only now be one explore showing under two models (finance & marketing). Also, the finance model will exclude marketing fields.

Notes:
* by repeating the connection name, we are overwriting the one previously specified.
* in the marketing file, avoid using `include: "*.view.lookml"` (or `include: "*.view.lkml"` in New LookML) - this can lead to certain files be included multiple times.

(andy) #2

For each old LookML code block in this article and its comments, we just added the New LookML equivalent code.


(Camille Vernon | Data Operations Analyst) #3

Just a note that the option to minimize the Old LookML code sections does not seem to be working. Thank you for adding the New LookML code sections to this article!


(Paul Stubley) #4

Also the New Lookml code isn’t formatted very well for the last block.