Types of files in a LookML project

A LookML project is a collection of LookML files that tell Looker how to connect to your database, how to query your data, and how to control the user interface's behavior. You can access LookML project files either from the Develop section in Looker or from the UI, as described on the Accessing LookML project files documentation page.

Project files are organized by your Looker developers using folders in the IDE.

A LookML project consists of at least one model file and at least one view file, and possibly some of the other types of files described on this page. All project files have extensions, although the extensions are hidden in the IDE list if your project isn't enabled for folders in the IDE.

Select the following links to get more information about each of the types of files that can be used in a LookML project:

Once you have created a LookML project, you can access the project files and add new files and folders to the project using the Looker IDE.

Model files

A model file specifies a database connection and the set of Explores that use that connection. A model file also defines the Explores themselves and their relationships to other views. An Explore is a starting point for querying your data. In SQL terms, an Explore is the FROM clause of a query. The Explores that you define in the model are seen by your users when they look at the Looker Explore menu.

In other words, the model file is where you define which data tables should be used (as included views) and how they should be joined together, if necessary.

Note the following about model files:

  • Explores are usually defined within a model file. However, sometimes you need a separate Explore file for a derived table, or to extend an Explore or to refine an Explore across models.
  • A model file must have a unique name across all projects on your instance. If your instance contains two .model.lkml files with the same name, it is likely that you will encounter errors, such as model configuration errors on the LookML Projects page and rendering errors for LookML dashboard errors, since LookML dashboards use the model name in their URL format (<hostname>/dashboard/model_name::<dashboard_name>). You can use the LookML Validator to verify if model names are duplicated across your instance. However, even if the LookML Validator detects duplicate model names on your instance, you can still push your code to production. Therefore, be sure to fix any duplicate model name errors before you deploy your LookML project to production.

See the Managing LookML files and folders documentation page for instructions for creating LookML project files, including model files.

Structure and general syntax

Within an Explore's curly braces, { }, you define parameters for the Explore. You can use join parameters to join other views to an Explore in a model file.

In the following example, the LookML in a sample model file defines an Explore called inventory_items, along with its joined views:

connection: "thelook_events"

explore: inventory_items {
  join: products {
    type: left_outer
    sql_on: ${inventory_items.product_id} = ${products.id} ;;
    relationship: many_to_one
  }

  join: distribution_centers {
    type: left_outer
    sql_on: ${products.distribution_center_id} = ${distribution_center.id} ;;
    relationship: many_to_one
  }
}

This LookML definition causes Inventory Items to appear in the Explore section of the Looker navigation and joins data from the products and distribution_centers views to the inventory_items view.

The Distribution Centers, Inventory Items, and Products views can be accessed from the field picker for the Inventory Items Explore.

For more specific information on the LookML structures in a model file, see the LookML terms and concepts documentation page.

Read the Model parameters, Explore parameters, and Join parameters documentation pages to learn more about LookML parameters in the model file.

View files

A view file generally defines a single "view" within Looker. A view corresponds to either a single table in your database or a single derived table. The view file specifies a table to query and the fields (dimensions and measures) to include from that table so that users can create queries with those fields in the Looker UI.

See the Managing LookML files and folders documentation page for instructions for creating LookML project files, including view files.

Structure and general syntax

Within each view's curly braces, { }, are field definitions, which usually correspond to a column in the underlying table or a calculation in Looker. Looker categorizes most of these definitions as either dimensions or measures.

In the following example of a view file, the orders.view file includes definitions for the id, status, and user_id dimensions, the created dimension group, and the count measure:

view: orders {
  sql_table_name: demo_db.orders ;;
  drill_fields: [id]

  dimension: id {
    primary_key: yes
    type: number
    sql: ${TABLE}.id ;;
  }

  dimension: status {
    type: string
    sql: ${TABLE}.status ;;
  }

  dimension: user_id {
    type: number
    # hidden: yes
    sql: ${TABLE}.user_id ;;
  }

    dimension_group: created {
    type: time
    timeframes: [
      raw,
      time,
      date,
      week,
      month,
      quarter,
      year
    ]
    sql: ${TABLE}.created_at ;;
  }

  measure: count {
    type: count
    drill_fields: [id, users.id, users.first_name, users.last_name, order_items.count]
  }
}

The definition of these fields in the orders view exposes the Created Date, ID,