Model Inheritance

  • 12 March 2015
  • 7 replies

What is the best way to do model inheritance in the short-term while Looker doesn’t support it?

7 replies

Daniel, can you give an example of what you’re trying to accomplish?

We have a staging model and a production model. They’re the same except with different connections. Currently we’ve put all of the explores into a file explores.dashboard.lookml but I was wondering if there’s a way to put these explores into explores.model.lookml without getting all of the errors about a connection being required in that file.

We don’t put connection definitions in our models. (We may not be required to because we only have 1 connection.) However, a fast and potentially valuable experiment is to make a new model file. Then cut and paste the base view definitions into the new file. Make sure the new model file does NOT have a connection definition. Then change the two dependent models to include the new model file (but don’t redefine the baseviews). Have the connection information in the two dependent model files. Save everything and test it.

Because you can include model files in other model files this could solve your problem.

Yeah that’s fine. It’d be nice if this were sorted into the Models section of the UI, but not a high priority.

I was beginning to migrate to a similar process @Daniel_Demetri, and had run into the slew of errors due to missing connections. I would like a better work around also, however this is what I ended up doing. Instead of using .dashboard.lookml, I created new files and named them .m.lookml. The nice thing is they show up in a separate area in the project under OTHER. Unfortunately they only can be initially created outside of Looker (via GitHub in my case).

The way I am actually using this is that I have multiple databases in production but only one is development. When pushing to production only the .m files are copied and the static .models simply handle the connection and include details.

Userlevel 3

@Daniel_Demetri and @jphilbert Good workaround you have going here. However, it seems somewhat inelegant that you need to use a dashboard file for this. I will put in a feature request to think of ways to improve this.

Userlevel 5

A belated update to this topic, in Looker 3.24 we introduced the extends LookML parameter. In short, it allows one to build off of views, adding new fields and filters. It’s really slick, I encourage everyone to take a look at this tutorial.