This page defines terms and concepts that appear repeatedly in LookML development. The following diagram shows the relationships among elements that are contained within other elements. All terms shown here are defined in the following sections.
Looks and user-defined dashboards are not part of this diagram, as users create them without using any LookML. However, their queries rely on the underlying LookML elements that are shown in the preceding diagram.
A project is a collection of LookML files that describe how your database tables are related to each other and how Looker should interpret those tables. Each LookML project resides in its own Git repository for version control.
Here are the common file types in a LookML project:
- A model contains information about which tables to use and how they should be joined together. Here you’ll typically define the model, its Explores, and its joins.
- A view contains information about how to access or calculate information from each table (or across multiple joined tables). Here you’ll typically define the view, its dimensions and measures, and its field sets.
- An Explore is often defined within a model file, but sometimes you need a separate Explore file for a derived table or to extend or refine an Explore across models.
- A manifest file can contain instructions for using files imported from another project or for your project’s localization settings.
See the LookML project files documentation page for information about other types of files you can have in your LookML project.
In Looker, you can access your projects under the Develop menu:
Where do LookML projects and files come from?
The most common way to create LookML files is to generate a LookML project from your database. You can also create a blank project and manually create its LookML files, or you can create a project by cloning an existing Git repository.
When you generate a new project from your database, Looker creates a baseline set of files that you can use as a template for building out the project:
- Multiple view files, one file for every table in the database.
- One model file. The model file declares an Explore for every view. Each Explore declaration includes
joinlogic to join any view that Looker can determine is related to the Explore.
From here, you can customize the project by removing unwanted views and Explores and by adding custom dimensions and measures.
Major LookML structures
As shown in the preceding diagram, a project typically contains one or more model files that contain parameters defining a model and its Explores and joins. In addition, projects typically contain one or more view files, each containing parameters defining that view and its fields (including dimensions and measures) and sets of fields. The project can also contain a project manifest file containing parameters to use view files from other projects or configure localization defaults. This section describes those major structures.
A model is a customized portal into the database, designed to provide intuitive data exploration for specific business users. Multiple models can exist for the same database connection in a single LookML project. Each model can expose different data to different users. For example, sales agents need different data than company executives, and so you would probably develop two models to offer views of the database appropriate for each user.
In Looker, queries are grouped by the model to which they belong. Your users see models listed under the Explore menu:
As of Looker 21.12, if your admin has enabled the Enhanced Navigation Labs feature, you can access Explores and view a list of Explores by selecting the Explore option in the new enhanced left navigation panel.
A model file specifies the database to connect to and defines a collection of Explores for that connection. By convention each file declares exactly one model and, in new LookML, model filenames end in
.model.lkml. The name of the model file determines the name that displays in Looker.
The general form of a model declaration in LookML is shown next. See the Model parameters documentation page for details.
A view declaration defines a list of fields (dimensions or measures) and their linkage to an underlying table or derived table. In LookML a view typically references an underlying database table, but it can also represent a derived table.
A view may join to other views. The relationship between views is typically defined as part of an Explore declaration in a model file.
In Looker, view names appear at the beginning of dimension and measure names in the data table. This naming convention makes it clear which view the field belongs to:
A view is stored in a
.view.lkml file. The general form of a view declaration is shown next. See the View parameters documentation page for complete usage details.
When you use a measure of
type: countin an Explore, the visualization labels the resulting values with the view name rather than the word “Count.” To avoid confusion, we recommend pluralizing your view name, selecting Show Full Field Name under Series in the visualization settings, or using a
view_labelwith a pluralized version of your view name.
An Explore is a view that users can query. You can think of the Explore as a starting point for a query, or in SQL terms, as the
FROM in a SQL statement. Not all views are Explores, because not all views describe an entity of interest. For example, a States view corresponding to a lookup table for state names doesn’t warrant an Explore, because business users never need to query it directly. On the other hand, business users probably want a way to query an Orders view, and so defining an Explore for Orders makes sense.
explore declaration specifies the join relationships to other views. Continuing with the previous examples, the Orders view might join the States view, identifying the state in which a sale occurred. See Joins for more detail.
In Looker, your users can see Explores listed in the Explore menu:
By convention, Explores are declared in the model file. The following example demonstrates the declaration for an
orders Explore for an e-commerce database. The views
customers are defined elsewhere, in their respective view files.
Dimension and measure fields
Views contain fields, mostly dimensions and measures, which are the fundamental building blocks for Looker queries.
In Looker, a dimension is a groupable field and can be used to filter query results. It can be:
- An attribute, which has a direct association to a column in an underlying table
- A fact or numerical value
- A derived value, computed based on the values of other fields in a single row
For example, dimensions for a Products view might include product name, product model, product color, product price, product created date, and product end-of-life date.
A measure is a field that uses a SQL aggregate function, such as
MAX. Any field computed based on the values of other measure values is also a measure. Measures can be used to filter grouped values. For example, measures for a Sales view might include total items sold (a count), total sale price (a sum), and average sale price (an average).
The behavior and expected values for a field depend on its declared type, such as
time. For measures, types include aggregate functions, such as
percent_of_previous. For details, refer to dimension types and measure types.
In Looker, fields are listed on the Explore page in the field picker on the left-hand side of the page.
By convention, fields are declared as part of the view they belong to, stored in a view file. The following example shows several dimension and measure declarations. Notice the use of the substitution operator (
$) to reference fields without using a fully scoped SQL column name.
Here are some example declarations of dimensions and measures:
See the Field parameters documentation page for complete details on declaring fields and the various settings that can be applied to them.
As part of an
explore declaration, each
join declaration specifies a view that can be joined into the
explore. When a user creates a query that includes fields from multiple views, Looker automatically generates SQL join logic to bring in all fields correctly.
Here is an example
join in an
For more details, check out Working with joins in LookML.
Project manifest files
Your project may contain a project manifest file, which is used for project-level settings such as those for specifying other projects to import into the current project, defining LookML constants, specifying model localization settings, and adding extensions and custom visualizations to your project.
Each project can have only one manifest file. The file must be named
manifest.lkml and be located at the root level of your Git repo. When you’re using folders in the IDE, be sure that the
manifest.lkml file is kept at the root level of your project’s directory structure.
You can use a project manifest file either for project import or for localization, but not for both functions.
To import LookML files from a different project, use the project manifest file to specify a name for your current project and the location of any external projects, which could be stored locally or remotely. For example:
For more information, see the Importing files from other projects documentation page.
To add localization to your model, use the project manifest file to specify default localization settings. For example:
Specifying default localization settings is one step in localizing your model. For more information, see the Localizing your LookML model documentation page.
In Looker, a set is a list that defines a group of fields that are used together. Typically sets are used to specify which fields to display after a user drills down into data. Drill sets are specified on a field-by-field basis, so you get complete control over what data is displayed when a user clicks a value in a table or dashboard. Sets can also be used as a security feature to define groups of fields visible to specific users.
The following example shows a set declaration in a view
order_items, defining fields that list relevant details about a purchased item. Note that the set references fields from other views by specifying scope.
set parameter documentation page for complete usage details for sets.
In Looker, you can drill down on any fields that are set up that way when writing LookML. Drilling works in both query results tables and dashboards. Drilling starts a new query that is restricted by the value you clicked on.
Drill behavior is different for dimensions and measures:
- When drilling on a dimension, the new query filters on the drilled value. For example, if you click on a specific date in a query of customer orders by date, the new query will show orders only on the specific date.
- When drilling on a measure, the new query will show the dataset that contributed to the measure. For example, when drilling on a count, the new query will show the rows to calculate that count. When drilling on max, min, and average measures, drilling still shows all the rows that contributed to that measure. This means that drilling on a max measure, for example, shows all the rows that were used to calculate the max value, not just a single row for the max value.
A derived table is a query whose results are used as if it were an actual table in the database. Derived tables are created by using the
derived_table parameter in a
view declaration. Looker accesses derived tables as though they were physical tables with their own set of columns. A derived table is exposed as its own view using the
derived_table parameter, and defines dimensions and measures in the same manner as conventional views. The view for a derived table can be queried and joined into other views, just like any other view.
Derived tables can also be defined as persistent derived tables (PDTs), which are derived tables that are written into a scratch schema on your database and automatically regenerated on the schedule that you specify with a persistence strategy.
See the Derived tables in Looker documentation page for more information.
Another important element of a LookML project is the database connection that Looker will use to run queries on your database. A Looker admin uses the Connections page to configure database connections, and LookML developers use the
connection parameter in a model file to specify which connection to use for the model. If you generate a LookML project from your database, Looker will automatically populate the
connection parameter in the model file.