Is extends really code reuse

I quite often find that I don’t want to ‘extend’ an existing explore, rather I want to ‘use’ an existing explore in a new explore. I don’t see how the LookML extends: can do this, which would be true code reuse.

Why do you think you can’t use extends?

If I create a VIEW in SQL that joins a number of tables, I can use that view as a virtual table anywhere in a future query and it’s joins. Can I use extends on explores to do the same?

Yes, you can extend an explore, use it as a base, and then add other joins if you’d like or configure other joins, override its settings, and so on..

1 Like

I want to be able to do something like the following:

explore: a {

join…

join…

}

explore: b {

join…

join: a

}

Explore is not a CTE so you can’t use it as a join. Now I kow what you mean. And no, you can’t just reuse parts of the code in all the places

2 Likes

Thanks for the confirmation. Perhaps I’m really asking for an ‘explore to explore join’ that is currently done by merge in Looker - but cannot be done in LookML.

extends is a specific form of code reuse.

Look into native derived tables

1 Like

Thanks. Yes, believe native derived tables can provide ‘real’ code re-use. But ideally it would be possible without introducing native DTs - and having to learn something else…

Hi @kuopaz

Have you managed to solve this as I am in a similar predicament.

as the Existing Explores have all the necessary joins and definitions how does a native derived table achieve this?