Hiding an explore for extending only

(Eric Feinstein) #1

Let’s say you are re-using a set of joins several times by taking advantage of our new lab feature extensions (3.24+). In doing this you may make a set of explores that you intend to extend a few different ways. The explores in that set on their own may not provide any value to your end-user, so why not hide them? Take this example:

- explore: order_items_joins
  view: order_items
  joins:
    - join: inventory_items
      foreign_key: inventory_item_id
      relationship: many_to_one
      
    - join: orders
      foreign_key: order_id
      relationship: many_to_one

- explore: product_joins
  view: products
  joins:
    - join: prices
      sql_on: ${products.price_id}=${prices.id}
      relationship: many_to_one
      
    - join: brands
      sql_on: ${products.brand_id}=${brand.id}
      relationship: many_to_one
      
      
- explore: order_item_products
  extends: [order_items_joins, product_joins]
  joins:
    - join: products
      sql_on: ${inventory_items.product_id} = ${products.id}
      relationship: many_to_one
      
- explore: order_item_users
  extends: order_items_joins
  joins:
    - join: users
      sql_on: ${orders.user_id}=${users.id}
      relationship: many_to_one

In it, I have two explores, one focusing on products, and one focusing on users. These use two other explores order_items_joins and product_joins as to define my joins once.

For fields within a view hidden: true will remove them from the field picker in the front end. To hide explores from my end-users, I add an extension: required parameter to my explore definition. That will make the explore only accessible via extending, like this:

- explore: order_items_joins
  view: order_items
  extension: required
  joins:
    - join: inventory_items
      foreign_key: inventory_item_id
      relationship: many_to_one
      
    - join: orders
      foreign_key: order_id
      relationship: many_to_one

- explore: product_joins
  view: products
  extension: required
  joins:
    - join: prices
      sql_on: ${products.price_id}=${prices.id}
      relationship: many_to_one
      
    - join: brands
      sql_on: ${products.brand_id}=${brand.id}
      relationship: many_to_one
      
      
- explore: order_item_products
  extends: [order_items_joins, product_joins]
  joins:
    - join: products
      sql_on: ${inventory_items.product_id} = ${products.id}
      relationship: many_to_one
      
- explore: order_item_users
  extends: order_items_joins
  joins:
    - join: users
      sql_on: ${orders.user_id}=${users.id}
      relationship: many_to_one

Now the user will only see the explores order_item_users and order_item_products

2 Likes