This page refers to the
extends
parameter that is part of a view.
extends
can also be used as part of an Explore, described on theextends
(for Explores) parameter documentation page.
extends
can also be used as part of a LookML dashboard, described on the Dashboard parameters documentation page.
Usage
view: view_name { extends: [view_name, view_name, ...] }
Hierarchy
extends |
Default Value
None
Accepts
Square brackets containing a comma-separated list of view names
|
Definition
The extends
parameter lets you build upon the content and settings from another view file, using the other view file as a starting point. If there are any conflicts, the extending view will use its own settings, overriding the settings of the view being extended. See Reusing code with extends for the details of how Looker does this.
Check out LookML refinements.
Extending a view or an Explore is ideal for scenarios where you want to have multiple versions of the view or Explore. But if your goal is simply to modify a view or an Explore without editing the LookML file that contains it, you may want to use a refinement instead. You can also use anextends
parameter inside a refinement. See the LookML refinements documentation page for more information and use cases.
When extending a view, it's important to use the sql_table_name
parameter on the view that is going to be extended, if it's not already there. The sql_table_name
parameter defines the table in your database that will be queried by a view. For any view the default value is the name of the view. So, if you aren't already using sql_table_name
, simply give it the same value as your view name.
It's also important that in our new view file we use the include
parameter to point to the filename of the view we want to extend.
Avoid extending views that are based on persistent derived tables (PDTs). Each extension of a PDT will create a new copy of the table in your database. In this case, you may want to use LookML refinements instead. See the LookML refinements documentation page for more information and use cases.
Example
Here's an example view file that we can extend. The view is named looker_events
and the view's filename is events.view
.
File: events.view
view: looker_events {
sql_table_name: looker_db.events ;;
# The normal contents of the view follow
}
Now we'll create a new view file and define a view that extends the looker_events
view. In our new file, we must use the include
parameter to point to the file name of the view we want to extend:
File: new_events.view
include: "events.view"
view: name_of_the_new_view {
extends: [looker_events]
measure: additional_measure {
type: count
}
# Additional things you want to add or change
}
And then we've added a new measure that will show in our new view in addition to all the dimensions and measures that are defined in the looker_events
view that we extended.
Using metadata to see extensions for an object
You can click on an explore
or a view
parameter in the Looker IDE and use the metadata panel to see any extensions on the object, or to see what object it extends. See the Metadata for LookML objects documentation page for information.
Things to consider
Some parameters are additive
In many cases, if the extending object contains the same parameter as the object that is being extended, the extending object's values will override the parameter values of the extended object.
But extensions can be additive for some parameters, meaning that the values from the extending object are used in conjunction with the values from the extended object.
The following parameters are additive:
For dimensions and measures:
For views:
extends
(you can chain together multipleextends
)
In the following example, the carriers
view has a name
dimension with a link
parameter:
view: carriers {
sql_table_name: flightstats.carriers ;;
dimension: name {
sql: ${TABLE}.name ;;
type: string
link: {
label: "Google {{ value }}"
url: "http://www.google.com/search?q={{ value }}"
icon_url: "http://google.com/favicon.ico"
}
}
}
And here is the carriers_extended
view, which extends the carriers
view. The carriers_extended
view also has a name
dimension with different settings in the link
parameter:
include: "/views/carriers.view.lkml"
view: carriers_extended {
extends: [carriers]
dimension: name {
sql: ${TABLE}.name ;;
type: string
link: {
label: "Dashboard for {{ value }}"
url: "https://docsexamples.dev.looker.com/dashboards/307?Carrier={{ value }}"
icon_url: "https://www.looker.com/favicon.ico"
}
}
}
In the carriers_extended
view, the two link
parameters are additive, so the name
dimension will have both links.
Projects with localization
When extending an object, be aware that localization rules apply to your extensions as well. If you are extending an object and then defining new labels or descriptions, you should provide localization definitions in your project's locale strings files. See the Localizing your LookML model documentation page for more information.