# Table of Contents - [Introduction to LookML  |  Looker  |  Google Cloud](#introduction-to-lookml-looker-google-cloud) - [LookML terms and concepts  |  Looker  |  Google Cloud](#lookml-terms-and-concepts-looker-google-cloud) - [Configuring the LookML Diagram  |  Looker  |  Google Cloud](#configuring-the-lookml-diagram-looker-google-cloud) - [Types of files in a LookML project  |  Looker  |  Google Cloud](#types-of-files-in-a-lookml-project-looker-google-cloud) - [LookML 对象的元数据  |  Looker  |  Google Cloud](#lookml-looker-google-cloud) - [Using the LookML Diagram  |  Looker  |  Google Cloud](#using-the-lookml-diagram-looker-google-cloud) - [LookML 优化  |  Looker  |  Google Cloud](#lookml-looker-google-cloud) - [Penajaman LookML  |  Looker  |  Google Cloud](#penajaman-lookml-looker-google-cloud) - [Validar seu LookML  |  Looker  |  Google Cloud](#validar-seu-lookml-looker-google-cloud) --- # Introduction to LookML  |  Looker  |  Google Cloud [Skip to main content](#main-content) [![Google Cloud](https://www.gstatic.com/devrel-devsite/prod/v02f7c7b934487be255c5f28ebb00ed6c2fde7a607ac1d91773e0036b0a06ec31/cloud/images/cloud-logo.svg)](/) / * English * Deutsch * Español – América Latina * Français * Indonesia * Italiano * Português – Brasil * 中文 – 简体 * 日本語 * 한국어 [Console](//console.cloud.google.com/) Sign in * [Looker](https://cloud.google.com/looker) [Contact Us](https://cloud.google.com/contact) [Start free](//console.cloud.google.com/freetrial) * [Home](https://cloud.google.com/) * [Looker](https://cloud.google.com/looker) * [Documentation](https://cloud.google.com/looker/docs) * [Guides](https://cloud.google.com/looker/docs/intro) Send feedback Introduction to LookML Stay organized with collections Save and categorize content based on your preferences. ================================================================================================================ LookML, short for _Looker Modeling Language_, is the language that is used in Looker to create semantic data models. You can use LookML to describe dimensions, aggregates, calculations, and data relationships in your SQL database. Looker uses a model that is written in LookML to construct SQL queries against a particular database. LookML is a dependency language like _make_, as opposed to an imperative language like C or Ruby. LookML provides predefined data types and syntax for data modeling. You don't need prior experience with programming languages to understand LookML. LookML is independent of particular SQL dialects, and it encapsulates SQL expressions to support any SQL implementation. For data analysts, LookML fosters DRY style ("don't repeat yourself"), meaning you write SQL expressions _once, in one place,_ and Looker uses the code repeatedly to generate ad hoc SQL queries. Business users can then use the results to build complex queries in Looker, focusing only on the content they need, not the complexities of SQL structure. LookML projects --------------- LookML is defined in _projects_. A LookML project is a collection of files including at least model and view files, and optionally [other types of files](/looker/docs/lookml-project-files) , that are typically version-controlled together through a Git repository. The model files contain information about which tables the project will use and how the tables should be joined. The view files describe how information is calculated about each table (or across multiple tables if the joins permit this). LookML separates structure from content, so the query structure (how tables are joined) is independent of the query content (the columns to access, derived fields, aggregate functions to compute, and filtering expressions to apply). ![](/static/looker/docs/images/dev-looker-query-flow-2110.png) Looker queries are based on LookML project files. Data analysts use LookML to create and maintain data models that define the data structure and business rules for the data that is being analyzed. The Looker SQL generator translates LookML into SQL, which lets business users query without writing any LookML or SQL. Business users use the Looker query builder, or the [Explore interface](/looker/docs/creating-and-editing-explores) , to create queries that are based on the data model that Looker analysts define. Users can select dimensions, measures, and filters to create custom queries that are based on their own questions and to generate their own insights. When a user creates a query, it is sent to the Looker SQL generator, which translates the query into SQL. The SQL query is executed against the database, and then Looker returns the formatted results to the user in the Explore interface. The user can then visualize the results and generate insights. For more details on the fundamental LookML elements in a project and how they relate to one another, see [LookML terms and concepts](/looker/docs/lookml-terms-and-concepts) . What users see -------------- How the project is set up, and the specific contents of its files, determines what users see and how they can interact with Looker. ![](/static/looker/docs/images/explore-page-all-1-2300.png) 1. The Explore panel in the [left navigation panel](/looker/docs/finding-content) is organized by [model](/looker/docs/lookml-terms-and-concepts#model) names. Under each model name is a list of available [Explores](/looker/docs/lookml-terms-and-concepts#explore) that are defined in that model. 2. Users can search for a specific Explore. 3. Developers can define descriptions for Explores, which users can view by hovering over the Explore name in the **Explore** menu. ![](/static/looker/docs/images/explore-page-all-2-2400.png) 4. The [field picker](/looker/docs/changing-explore-menu-and-field-picker#field_picker) pane is organized by [view](/looker/docs/lookml-terms-and-concepts#view) names. Under each view name is a list of available fields from the tables included in that view. Most views show both [dimensions](/looker/docs/reference/param-dimension-filter-parameter-types) and [measures](/looker/docs/reference/param-measure-types) . This example selects a **Month** dimension from within a **Returned Date** dimension group, which was defined in the view file. 5. Users can select multiple measures on which to base the query. 6. Users can apply options like filters and pivots in the field picker pane. 7. Users can refine the terms of the query. 8. Users can choose a [visualization type](/looker/docs/visualization-types) to apply to the query results. 9. Running this Explore generates a SQL query that returns both a data table and a visualization of the total sale price and total gross margin of the returned orders from the past year. Code sample ----------- The following code example shows a minimal LookML project for an e-commerce store, which has a model file — `ecommercestore.model.lkml` — and two view files — `orders.view.lkml` and `customers.view.lkml`: ###################################### # FILE: ecommercestore.model.lkml # # Define the explores and join logic # ###################################### connection: order_database include: "*.view.lkml" explore: orders { join: customers { sql_on: ${orders.customer_id} = ${customers.id} ;; } } ########################################################## # FILE: orders.view.lkml # # Define the dimensions and measures for the ORDERS view # ########################################################## view: orders { dimension: id { primary_key: yes type: number sql: ${TABLE}.id ;; } dimension: customer_id { # field: orders.customer_id sql: ${TABLE}.customer_id ;; } dimension: amount { # field: orders.amount type: number value_format: "0.00" sql: ${TABLE}.amount ;; } dimension_group: created { # generates fields: type: time # orders.created_time, orders.created_date timeframes: [time, date, week, month] # orders.created_week, orders.created_month sql: ${TABLE}.created_at ;; } measure: count { # field: orders.count type: count # creates a sql COUNT(*) drill_fields: [drill_set*] # list of fields to show when someone clicks 'ORDERS Count' } measure: total_amount { type: sum sql: ${amount} ;; } set: drill_set { fields: [id, created_time, customers.name, amount] } } ############################################################# # FILE: customers.view.lkml # # Define the dimensions and measures for the CUSTOMERS view # ############################################################# view: customers { dimension: id { primary_key: yes type: number sql: ${TABLE}.id ;; } dimension: city { # field: customers.city sql: ${TABLE}.city ;; } dimension: state { # field: customers.state sql: ${TABLE}.state ;; } dimension: name { sql: CONCAT(${TABLE}.firstname, " ", ${TABLE}.lastname) ;; } measure: count { # field: customers.count type: count # creates a sql COUNT(*) drill_fields: [drill_set*] # fields to show when someone clicks 'CUSTOMERS Count' } set: drill_set { # set: customers.drill_set fields: [id, state, orders.count] # list of fields to show when someone clicks 'CUSTOMERS Count' } } Additional resources -------------------- If you are new to LookML development, consider using the resources described in the following sections to accelerate your learning: * [Get access to Looker's learning environment](#get_access_to_lookers_learning_environment) * [Learn how to use Looker to query and explore data](#learn_how_to_use_looker_to_query_and_explore_data) * [Review SQL basics before diving into LookML](#review_sql_basics_before_diving_into_lookml) * [Learn LookML fundamentals](#learn_lookml_fundamentals) ### Get access to Looker's learning environment Check out the courses on [Google Cloud Skills Boost](https://www.cloudskillsboost.google/paths/28) . ### Learn how to use Looker to query and explore data Knowing how to explore data in Looker will help you a great deal when you're modeling your data in LookML. If you're not familiar with using Looker to query, filter, and drill into data, we suggest the following resources: * Start with the [Retrieve and chart data](/looker/docs/retrieve-and-chart-data) tutorials. The links at the bottom of each page will guide you through a sequence of the most important Looker features. * [The Analyzing and Visualizing Data in Looker skills boost quest](https://www.cloudskillsboost.google/paths/28/course_templates/323) will take you through the basics of exploring. ### Review SQL basics before diving into LookML Writing LookML requires an understanding of SQL queries. You don't have to be a SQL expert, and even beginners can create powerful Looker models. But, in general, the deeper you go in LookML, the more you benefit from a deeper knowledge of SQL. If you need a SQL refresher, here are some of our favorite resources: * [Khan Academy's SQL Lessons](https://www.khanacademy.org/computing/computer-programming/sql) interactive SQL tutorials * [SQLZoo](http://sqlzoo.net/wiki/Main_Page) interactive SQL tutorials * [Sams Teach Yourself SQL in 10 Minutes](https://www.google.com/search?q=sql+in+10+minutes+sams+teach+yourself) book by Ben Forta ### Learn LookML fundamentals These resources will jump-start your LookML knowledge. Use your learning account to experiment with different design patterns. * Start with [LookML terms and concepts](/looker/docs/lookml-terms-and-concepts) . * Continue to [How Looker generates SQL](/looker/docs/how-looker-generates-sql) and [Advanced LookML concepts](/looker/docs/additional-lookml-basics) . * Once you have a good grasp of LookML and SQL, read about our more advanced features like [derived tables](/looker/docs/derived-tables) and [templated filters](/looker/docs/templated-filters) . After you've learned LookML basics, see the following pages for overviews of the different types of LookML parameters: * [Model parameters](/looker/docs/reference/param-model) * [Explore parameters](/looker/docs/reference/param-explore) * [Join parameters](/looker/docs/reference/param-join) * [View parameters](/looker/docs/reference/param-view) * [Field parameters](/looker/docs/reference/param-field) * [Dashboard parameters](/looker/docs/reference/param-lookml-dashboard) Send feedback Except as otherwise noted, the content of this page is licensed under the [Creative Commons Attribution 4.0 License](https://creativecommons.org/licenses/by/4.0/) , and code samples are licensed under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0) . For details, see the [Google Developers Site Policies](https://developers.google.com/site-policies) . Java is a registered trademark of Oracle and/or its affiliates. Last updated 2025-04-17 UTC. --- # LookML terms and concepts  |  Looker  |  Google Cloud [Skip to main content](#main-content) [![Google Cloud](https://www.gstatic.com/devrel-devsite/prod/v02f7c7b934487be255c5f28ebb00ed6c2fde7a607ac1d91773e0036b0a06ec31/cloud/images/cloud-logo.svg)](/) / * English * Deutsch * Español – América Latina * Français * Indonesia * Italiano * Português – Brasil * 中文 – 简体 * 日本語 * 한국어 [Console](//console.cloud.google.com/) Sign in * [Looker](https://cloud.google.com/looker) [Contact Us](https://cloud.google.com/contact) [Start free](//console.cloud.google.com/freetrial) * [Home](https://cloud.google.com/) * [Looker](https://cloud.google.com/looker) * [Documentation](https://cloud.google.com/looker/docs) * [Guides](https://cloud.google.com/looker/docs/intro) Send feedback LookML terms and concepts Stay organized with collections Save and categorize content based on your preferences. =================================================================================================================== This page defines the following core terms and concepts, which you will likely encounter often during [LookML](/looker/docs/what-is-lookml) development: * [LookML projects](#lookml_project) * [Major LookML structures (like models, views, and Explores)](#major_lookml_structures) * [Derived tables](#derived_tables) * [Database connections](#database_connection) * [Case sensitivity](#case_sensitivity) [Looks](/looker/docs/saving-and-editing-looks) and [user-defined dashboards](/looker/docs/creating-user-defined-dashboards) are not described on this page, as users create them without using any LookML. However, their queries rely on the underlying LookML elements that are discussed on this page. See the [Looker glossary](/looker/docs/glossary) for a comprehensive list of terms and definitions that are used throughout Looker. For a comprehensive overview of the LookML parameters you can use in a LookML project, see the [LookML quick reference](/looker/docs/reference/lookml-quick-reference) page. See the [Looker and Looker Studio shared terms and concepts](/looker/docs/looker-and-studio-shared-terms-glossary) documentation page for information about the nuances between similar terms and concepts in Looker and Looker Studio. LookML project -------------- In Looker, a project is a collection of files that describe the objects, database connections, and user interface elements that will be used to carry out [SQL queries](/looker/docs/how-looker-generates-sql) . At the most basic level, these files describe how your database tables relate to each other and how Looker should interpret them. The files may also include [LookML](/looker/docs/what-is-lookml) parameters that define or change the options that are presented in Looker's UI. Each LookML project resides in its own Git repository for [version control](/looker/docs/version-control-and-deploying-changes) . Once you [connect Looker to your database](/looker/docs/connecting-to-your-db) , you can specify the database [connection](/looker/docs/reference/param-model-connection) to use for your Looker project. ![](/static/looker/docs/images/dev-project-structure-2116.png) You can access your projects from the **Develop** menu in Looker (see [Accessing project files](/looker/docs/accessing-project-files) for details and other options). ![](/static/looker/docs/images/develop-projects-list-2116.png) See the [Generating a model](/looker/docs/generating-a-model) documentation page for information on creating a new project, and see the [Accessing and editing project information](/looker/docs/manage-projects) documentation page for information on accessing and making changes to existing LookML projects. ### Parts of a project ![A LookML project can contain models, views, and LookML dashboards, each of which is made up other LookML elements.](/static/looker/docs/images/lookml_object_hierarchy.png) As shown in the diagram, the following are some of the more common types of files in a LookML project: * A [model](/looker/docs/lookml-terms-and-concepts#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](/looker/docs/lookml-terms-and-concepts#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](/looker/docs/lookml-terms-and-concepts#explore) is often defined within a model file, but sometimes you need a separate Explore file [for a derived table](/looker/docs/creating-ndts#using_includes_to_enable_referencing_fields) or to [extend](/looker/docs/reference/param-explore-extends#extending_an_explore_across_models) or [refine](/looker/docs/lookml-refinements) an Explore across models. * A [manifest file](/looker/docs/reference/param-project-manifest) can contain instructions for using files [imported](/looker/docs/importing-projects) from another project or for your project's localization settings. In addition to model, view, Explore, and manifest files, a project can have other types of files related to things like built-in dashboards, documentation, localization, and more. See the [LookML project files](/looker/docs/lookml-project-files#project_file_types) documentation page for more information about these types of files as well as the other types of files that you can have in your LookML project. These files together make up one project. If you are using Git for [version control](/looker/docs/version-control-and-deploying-changes) , then each project is typically backed up by its own Git repository. ### 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](/looker/docs/generating-a-model) . You can also [create a blank project](/looker/docs/generating-a-model#blank-project) and manually create its LookML files. 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](#view) files, one file for every table in the database. * One [model](#model) file. The model file declares an [Explore](#explore) for every view. Each Explore declaration includes [`join`](#join) logic 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 [parts of a project diagram](#parts_of_a_project) , a project typically contains one or more model files, which contain parameters that define a model and its Explores and joins. In addition, projects typically contain one or more view files, each containing parameters that define that view and its fields (including dimensions and measures) and sets of fields. The project can also contain a project manifest file, which lets you configure project-level settings. This section describes those major structures. ### Model 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. A model specifies a [connection](#database_connection) to a single database. A developer also defines a model's [**Explores**](#explore) within the model file. By default, Explores are organized under the model name in which they are defined. Your users see models listed in the **Explore** menu. ![](/static/looker/docs/images/develop-model-list-2308.png) See the [Types of files in a LookML project](/looker/docs/lookml-project-files#model_files) documentation page for more information about model files, including the [structure and general syntax of model files](/looker/docs/lookml-project-files#structure_and_general_syntax) . See the [Model parameters](/looker/docs/reference/param-model) documentation page for details about the LookML parameters that can be used in a model file. ### View A view declaration defines a list of [fields](#field) (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](#derived-table) . A view may join to other views. The relationship between views is typically defined as part of an [Explore](#explore) declaration in a model file. By default, view names appear at the beginning of dimension and measure names in the Explore data table. This naming convention makes it clear which view the field belongs to. In the following example, the view names **Orders** and **Users** are listed before the names of the fields in the data table: ![Data table for a sample query with the Orders Created Date, Users ID, and Orders Count fields selected.](/static/looker/docs/images/dev-explore-views-2312.png) See the [Types of files in a LookML project](/looker/docs/lookml-project-files#view_files) documentation for more information about view files, including the [structure and general syntax of view files](/looker/docs/lookml-project-files#structure_and_general_syntax_2) . See the [View parameters](/looker/docs/reference/param-view) documentation page for details about the LookML parameters that can be used in a view file. ### Explore An [Explore](/looker/docs/creating-and-editing-explores#explores_are_the_starting_point_for_exploration) 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 that corresponds 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. See the [Viewing and interacting with Explores in Looker](/looker/docs/viewing-and-interacting-with-explores) documentation page for information on how users interact with Explores to query your data. In Looker, your users can see Explores listed in the **Explore** menu. Explores are listed below the names of the models they belong to. ![](/static/looker/docs/images/develop-explore-list-2116.png) By convention, Explores are declared in the [model file](/looker/docs/lookml-project-files#model_files) with the [`explore`](/looker/docs/reference/param-explore-explore) parameter. In this following example of a model file, the `orders` Explore for an ecommerce database is defined within the model file. The views `orders` and `customers` that are referenced within the `explore` declaration are defined elsewhere, in their respective view files. connection: order_database include: "filename_pattern" explore: orders { join: customers { sql_on: ${orders.customer_id} = ${customers.id} ;; } } In this example, the [`connection`](/looker/docs/reference/param-model-connection) parameter is used to specify the [database connection](#database_connection) for the model, and the [`include`](/looker/docs/reference) parameter is used to specify the files that will be available for the model to reference. The `explore` declaration in this example also specifies join relationships between views. For details on `join` declarations, visit the section on [joins](#join) on this page. Visit the [Join parameters](/looker/docs/reference/param-join) documentation page for more details about the LookML parameters that can be used with the `join` parameter. ### Dimension and measure fields [Views](#view) 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 any of the following: * 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 In Looker, dimensions always appear in the `GROUP BY` clause of the SQL that Looker generates. 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 `COUNT`, `SUM`, `AVG`, `MIN`, or `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 `string`, `number`, or `time`. For measures, types include aggregate functions, such as `sum` and `percent_of_previous`. For details, refer to [dimension types](/looker/docs/reference/param-dimension-filter-parameter-types) and [measure types](/looker/docs/reference/param-measure-types) . In Looker, fields are listed on the **Explore** page in the [field picker](/looker/docs/changing-explore-menu-and-field-picker#field_picker_display_overview) on the left side of the page. You can expand a view in the field picker to show the list of fields that are available to query from that view. ![](/static/looker/docs/images/dev-explore-dimensions-measures-2312.png) 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 (`$`)](/looker/docs/sql-and-referring-to-lookml#substitution) to reference fields without using a fully scoped SQL column name. Here are some example declarations of dimensions and measures: view: orders { dimension: id { primary_key: yes type: number sql: ${TABLE}.id ;; } dimension: customer_id { sql: ${TABLE}.customer_id ;; } dimension: amount { type: number value_format: "0.00" sql: ${TABLE}.amount ;; } dimension_group: created { type: time timeframes: [date, week] sql: ${TABLE}.created_at ;; } measure: count { type: count # creates sql COUNT(orders.id) sql: ${id} ;; } measure: total_amount { type: sum # creates sql SUM(orders.amount) sql: ${amount} ;; } } You can also define a [`dimension_group`](/looker/docs/reference/param-field-dimension-group) , which creates multiple time-related dimensions at once, and [`filter` fields](/looker/docs/reference/param-field-filter) , which have a variety of advanced use cases such as [templated filters](/looker/docs/templated-filters) . See the [Field parameters](/looker/docs/reference/param-field) documentation page for complete details on declaring fields and the various settings that can be applied to them. ### Joins As part of an `explore` declaration, each `join` declaration specifies a view that can be joined into the [Explore](#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 `explore` declaration: # file: ecommercestore.model.lookml connection: order_database include: "filename_pattern" # include all the views explore: orders { join: customers { sql_on: ${orders.customer_id} = ${customers.id} ;; } } For more details, visit the [Working with joins in LookML](/looker/docs/working-with-joins) documentation page. ### Project manifest files Your project may contain a [project manifest file](/looker/docs/other-project-files#project_manifest_files) , which is used for project-level settings such as those for specifying other projects to [import into the current project](/looker/docs/importing-projects) , defining [LookML constants](/looker/docs/sql-and-referring-to-lookml#lookml_constants) , specifying [model localization settings](/looker/docs/model-localization) , and adding [extensions](/looker/docs/intro-to-extension-framework#adding_an_extension_to_looker) and [custom visualizations](/looker/docs/reference/param-manifest-visualization) 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 repository. When you're using [folders in the IDE](/looker/docs/ide-folders) , make sure that the `manifest.lkml` file is kept at the root level of your project's directory structure. 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: # This project project_name: "my_project" # The project to import local_dependency: { project: "my_other_project" } remote_dependency: ga_360_block { url: "https://github.com/llooker/google_ga360" ref: "4be130a28f3776c2bf67a9acc637e65c11231bcc" } After defining the external projects in the project manifest file, you can use the [`include`](/looker/docs/reference/param-model-include) parameter in your [model file](#model) to add files from those external project to your current project. For example: include: "//my_other_project/imported_view.view" include: "//ga_360_block/*.view" For more information, see the [Importing files from other projects](/looker/docs/importing-projects) documentation page. To add localization to your model, use the project manifest file to specify default localization settings. For example: localization_settings: { default_locale: en localization_level: permissive } Specifying default localization settings is one step in localizing your model. For more information, see the [Localizing your LookML model](/looker/docs/model-localization) documentation page. ### Sets 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](#drill) 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 that are 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: order_items_stats_set { fields: [\ id, # scope defaults to order_items view\ orders.created_date, # scope is "orders" view\ orders.id,\ users.name,\ users.history, # show all products this user has purchased\ products.item_name,\ products.brand,\ products.category,\ total_sale_price\ ] } See the [`set`](/looker/docs/reference/param-view-set) parameter documentation page for complete usage details for sets. ### Drill down In Looker, you can configure a field so that users can further drill down into the data. Drilling works both in query results tables and in dashboards. Drilling starts a new query that is restricted by the value that you click on. Drill behavior is different for dimensions and measures: * When you drill on a dimension, the new query filters on the drilled value. For example, if you click the specific date in a query of customer orders by date, the new query will show orders only on that 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. The fields to show for the new drill query can be defined by a [set](#set) , or can be defined by the [`drill_fields` parameter (for fields)](/looker/docs/reference/param-field-drill-fields) or the [`drill_fields` parameter (for views)](/looker/docs/reference/param-view-drill-fields) . Derived tables -------------- 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`](/looker/docs/reference/param-view-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, 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)_](/looker/docs/derived-tables#persistent_derived_table) , 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](/looker/docs/derived-tables#adding_persistence) . See the [Derived tables in Looker](/looker/docs/derived-tables) documentation page for more information. Database connection ------------------- Another important element of a LookML project is the database connection that Looker uses to run queries on your database. A Looker admin uses the [Connections page](/looker/docs/connecting-to-your-db) to configure database connections, and LookML developers use the [`connection` parameter](/looker/docs/reference/param-model-connection) in a [model file](#model) to specify which connection to use for the model. If you [generate a LookML project from your database](/looker/docs/generating-a-model) , Looker automatically populates the `connection` parameter in the model file. Case sensitivity ---------------- LookML is case-sensitive, so be sure to match the case when referring to LookML elements. Looker alerts you if you have referred to an element that doesn't exist. For example, suppose you have an Explore called `e_flights_pdt`, and a LookML developer uses incorrect capitalization (`e_FLIGHTS_pdt`) to reference that Explore. In this example, the Looker IDE shows a warning that the Explore `e_FLIGHTS_pdt` does not exist. In addition, the IDE suggests the name of an existing Explore, which is `e_flights_pdt`: ![](/static/looker/docs/images/dev-case-sensitive-74.png) However, if your project contained both `e_FLIGHTS_pdt` and `e_flights_pdt`, the Looker IDE would not be able to correct you, so you would have to be sure which version you intended. Generally, it's a good idea to stick with lowercase when naming LookML objects. [IDE folder](/looker/docs/ide-folders) names are also case-sensitive. You must match the capitalization of folder names whenever you specify file paths. For example, if you have a folder named `Views`, you must use this same capitalization in the [`include`](/looker/docs/reference/param-model-include) parameter. Again, the Looker IDE will indicate an error if your capitalization doesn't match an existing folder in your project: ![The Looker IDE displays a warning stating that the include does not match any files.](/static/looker/docs/images/dev-case-sensitive-path-74.png) Send feedback Except as otherwise noted, the content of this page is licensed under the [Creative Commons Attribution 4.0 License](https://creativecommons.org/licenses/by/4.0/) , and code samples are licensed under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0) . For details, see the [Google Developers Site Policies](https://developers.google.com/site-policies) . Java is a registered trademark of Oracle and/or its affiliates. Last updated 2025-04-17 UTC. --- # Configuring the LookML Diagram  |  Looker  |  Google Cloud [Skip to main content](#main-content) [![Google Cloud](https://www.gstatic.com/devrel-devsite/prod/v02f7c7b934487be255c5f28ebb00ed6c2fde7a607ac1d91773e0036b0a06ec31/cloud/images/cloud-logo.svg)](/) / * English * Deutsch * Español – América Latina * Français * Indonesia * Italiano * Português – Brasil * 中文 – 简体 * 日本語 * 한국어 [Console](//console.cloud.google.com/) Sign in * [Looker](https://cloud.google.com/looker) [Contact Us](https://cloud.google.com/contact) [Start free](//console.cloud.google.com/freetrial) * [Home](https://cloud.google.com/) * [Looker](https://cloud.google.com/looker) * [Documentation](https://cloud.google.com/looker/docs) * [Guides](https://cloud.google.com/looker/docs/intro) Send feedback Configuring the LookML Diagram Stay organized with collections Save and categorize content based on your preferences. ======================================================================================================================== The LookML Diagram is an extension — a web application built using Looker components — developed using the Looker [extension framework](/looker/docs/intro-to-extension-framework) and deployed through the [Looker Marketplace](/looker/docs/marketplace) . This documentation page describes the tasks that Looker admins must complete before [Looker users can access and use the extension](/looker/docs/lookml-diagram-using) , including: 1. Enable the appropriate [features](#lookml_diagram_labs) . 2. [Install the LookML Diagram extension](#installing_the__lookml_diagram) . 3. [Grant permissions to access the LookML Diagram](#granting_permissions_to_use_the_lookml_diagram) . Enabling required features -------------------------- Before installing the LookML Diagram from the [Marketplace](/looker/docs/marketplace) , Looker admins must enable these features: * [**Marketplace**](/looker/docs/admin-panel-platform-marketplace) : To access the Looker Marketplace (enabled by default) * [**Extension Framework**](/looker/docs/admin-panel-platform-extension-framework) : To deploy extensions developed using the Looker extension framework (enabled by default) Installing the LookML Diagram ----------------------------- Installing applications and tools — such as extensions — from the Marketplace requires [`develop`](/looker/docs/admin-panel-users-roles#develop) , [`manage_models`](/looker/docs/admin-panel-users-roles#manage-models) , and [`deploy`](/looker/docs/admin-panel-users-roles#deploy) [permissions](/looker/docs/admin-panel-users-roles#permissions_list) . The LookML Diagram extension is listed in the **Applications** section of the Looker Marketplace. See the [Using the Looker Marketplace](/looker/docs/marketplace#installing_a_tool_from_the_marketplace) documentation page for more detailed instructions on installing a tool from the Looker Marketplace. After you've installed the extension, you can ensure that you always have the most updated version by going to the Looker Marketplace, clicking **Manage**, and clicking the **Update** button next to the extension. Granting permissions to use the LookML Diagram ---------------------------------------------- After the LookML Diagram is installed, a model called `lookml-diagram` is automatically added to the list of available models on the [**New Model Set**](/looker/docs/admin-panel-users-roles#creating_a_model_set) and [**Edit Model Set**](/looker/docs/admin-panel-users-roles#editing_a_model_set) pages, accessible from the **Roles** page in the **Admin** panel. Looker admins must enable users to perform certain tasks with the LookML Diagram extension by granting [permissions](/looker/docs/admin-panel-users-roles#permissions_list) to the `lookml-diagram` model and any models the user needs to work with in the LookML Diagram. To enjoy full functionality of the LookML Diagram, users must have `explore` and `deploy` permissions. Refer to the following table for details. | Permission | Depends on | Extension capabilities | | --- | --- | --- | | [`access_data`](/looker/docs/admin-panel-users-roles#access_data) | None | Users can navigate to the extension but won't be able to interact with it. | | [`explore`](/looker/docs/admin-panel-users-roles#explore) | `see_looks`, `access_data` | Users can view and interact with the diagram and can access Explores. **Go to LookML** links are visible but not functional. Users cannot switch or select Git branches in the **Diagram Settings** panel. | | [`develop`](/looker/docs/admin-panel-users-roles#develop) | `see_lookml`, `see_looks`, `access_data` | Users can interact with the diagram and can access LookML project files. **Explore from Field** links are visible but the user is directed to a page that they are not authorized to access. Users cannot switch or select Git branches in the **Diagram Settings** panel. | | [`deploy`](/looker/docs/admin-panel-users-roles#deploy) | `develop`, `see_lookml`, `see_looks`, `access_data` | The same as with `develop` except that users _can_ switch or select Git branches in the **Diagram Settings** panel. Users can use the extension while in Development Mode. | See the [Setting permissions for Looker extensions](/looker/docs/setting-permissions-for-extensions) documentation page for more information on granting users permissions to access and use extensions. Send feedback Except as otherwise noted, the content of this page is licensed under the [Creative Commons Attribution 4.0 License](https://creativecommons.org/licenses/by/4.0/) , and code samples are licensed under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0) . For details, see the [Google Developers Site Policies](https://developers.google.com/site-policies) . Java is a registered trademark of Oracle and/or its affiliates. Last updated 2025-04-17 UTC. --- # Types of files in a LookML project  |  Looker  |  Google Cloud [Skip to main content](#main-content) [![Google Cloud](https://www.gstatic.com/devrel-devsite/prod/v02f7c7b934487be255c5f28ebb00ed6c2fde7a607ac1d91773e0036b0a06ec31/cloud/images/cloud-logo.svg)](/) / * English * Deutsch * Español – América Latina * Français * Indonesia * Italiano * Português – Brasil * 中文 – 简体 * 日本語 * 한국어 [Console](//console.cloud.google.com/) Sign in * [Looker](https://cloud.google.com/looker) [Contact Us](https://cloud.google.com/contact) [Start free](//console.cloud.google.com/freetrial) * [Home](https://cloud.google.com/) * [Looker](https://cloud.google.com/looker) * [Documentation](https://cloud.google.com/looker/docs) * [Guides](https://cloud.google.com/looker/docs/intro) Send feedback Types of files in a LookML project Stay organized with collections Save and categorize content based on your preferences. ============================================================================================================================ A LookML [project](/looker/docs/lookml-terms-and-concepts#lookml_project) is a collection of [LookML](/looker/docs/what-is-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](/looker/docs/accessing-project-files) documentation page. Project files are organized by your Looker developers using [folders in the IDE](/looker/docs/ide-folders) . 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](/looker/docs/ide-folders) . Select the following links to get more information about each of the types of files that can be used in a LookML project: * [Model files](#model_files) with extension `.model.lkml` * [View files](#view_files) with extension `.view.lkml` * [Dashboard files](#dashboard_files) with extension `.dashboard.lookml` * [Data files](#data_files) with extension `.topojson` or `.geojson` or `.json` * [Document files](#document_files) with extension `.md` * [Project manifest files](#project_manifest_files) that are always named `manifest.lkml` * [Manifest lock files](#manifest_lock_files) with extension `.lkml` * [Locale strings files](#locale_strings_files) with extension `.strings.json` * [Explore files](#explore_files) with extension `.explore.lkml` * [Data test files](#data_test_files) with extension `.lkml` * [Refinements files](#refinements_files) with extension `.lkml` * [Other files](#other_files) with any file extension not previously listed Once you have [created a LookML project](/looker/docs/generating-a-model) , you can [access the project files](/looker/docs/accessing-project-files) and [add new files and folders to the project](/looker/docs/creating-project-files) using the Looker IDE. Model files ----------- A model file specifies a database connection and the set of [Explores](/looker/docs/lookml-terms-and-concepts#explore) 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](#view_files) ) and how they should be joined together, if necessary. See the [Managing LookML files and folders](/looker/docs/creating-project-files#creating_files) 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](/looker/docs/finding-content) 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.](/static/looker/docs/images/model-lookml-ui-example-2214.png) For more specific information on the LookML structures in a model file, see the [LookML terms and concepts](/looker/docs/lookml-terms-and-concepts#model) documentation page. Read the [Model parameters](/looker/docs/reference/param-model) , [Explore parameters](/looker/docs/reference/param-explore) , and [Join parameters](/looker/docs/reference/param-join) 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](/looker/docs/derived-tables) . 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](/looker/docs/creating-project-files#creating_files) 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**, **Status**, **User ID**, and **Count** fields in the field picker for the **Orders** Explore. ![](/static/looker/docs/images/view-structure-ui-example-2308.png) Users who have access to the **Orders** Explore can query the **Orders** Explore by selecting and filtering on these fields. In addition to dimensions and measures, you can also create several time-based dimensions at once using [dimension groups](/looker/docs/reference/param-field-dimension-group) or specify a filter for your users with [filter fields](/looker/docs/reference/param-field-filter) . Visit the [View parameters](/looker/docs/reference/param-view) documentation page to learn more about LookML parameters in view files, and visit the [Field parameters](/looker/docs/reference/param-field) documentation page for information about the LookML parameters used to define dimensions, measures, dimension groups, and filter fields in LookML. Dashboard files --------------- Looker supports two types of dashboards: * **User-defined dashboards**, which can be created by non-developer users without using LookML. For details, see the [Creating user-defined dashboards](/looker/docs/creating-user-defined-dashboards) documentation page. * **LookML dashboards**, which are stored as version-controlled files that are associated with the project. If your project contains LookML dashboards, they will be defined in dedicated dashboard files in the IDE, with the extension `.dashboard.lookml`. For more information on LookML dashboards, see the [Creating LookML dashboards](/looker/docs/building-lookml-dashboards) documentation page. Document files -------------- Looker document files let you write documentation or other notes about your Looker data model using [GitHub-flavored Markdown](https://help.github.com/categories/writing-on-github/) . This can be helpful for your users to become acquainted with how your organization uses Looker. See the [Managing LookML files and folders](/looker/docs/creating-project-files#creating_files) documentation page for instructions for creating LookML project files, including document files. ### Viewing the document outside the IDE To see a document outside the IDE, which you will need to do to take advantage of the [navigation features](#doc_nav) described on this page, choose the **View Document** option from the **See file actions** menu for the document file: ![](/static/looker/docs/images/dev-doc-view-doc-2500.png) You can distribute the URL of the resulting page to other users so that they can directly access the document without having to navigate through the Looker **Develop** menu to reach it. ### Adding a navigation structure to your document You can add a sidebar to your document files so that users can see the structure of the information and navigate between documents. ![](/static/looker/docs/images/dev-doc-navigation-2300.png) To add sidebar navigation for a document, create a navigation section starting on the first line of the document. Mark the start and end of your navigation section with three dashes (`---`). You can use the following parameters in the navigation section: * [`navigation`](#navigation) * [`title`](#title) * [`section`](#section) * [`label`](#label) #### `navigation` You can use `navigation: true` in a document file to add the navigation sidebar to that document. For example, you can add the following code to the top of a Markdown file: --- navigation: true --- ![](/static/looker/docs/images/dev-doc-navigation-file-2206.png) This code adds to the document a navigation sidebar with links to all the project's documents. If you include only `navigation: true` in a document, the sidebar of that document lists all the project's documents in alphabetical order by filename. Also, you might find that organizing by alphabetical filename is not ideal, or you may have some documents that you don't want to appear in the navigation: ![The sidebar lists Document Four, Document One, Document Three, and Document Two in alphabetical order, along with a document titled Do Not Display.](/static/looker/docs/images/dev-doc-navigation-no-2220.png) In this example, you might want to list the documents **Document One**, **Document Two**, **Document Three**, and **Document Four** in numerical order rather than alphabetical order as well as to hide the document **Do Not Display** from the navigation sidebar. To change the order of the documents in the navigation sidebar, or to show only a subset of your documents in the sidebar, you can use this format: --- navigation: - document_one - document_two - document_three - document_four --- Now the navigation will show only the document files that you want to be shown, and they will appear in a more logical order: ![The sidebar lists the documents in numerical order, and the document Do Not Display is no longer shown.](/static/looker/docs/images/dev-doc-navigation-yes-2300.png) #### `title` By default, the sidebar displays the document's heading (if the document begins with a heading), or the document's filename if there is no heading in the file. You can add a `title` parameter at the top of a document to change how the document is displayed in navigation sidebars: --- title: New Title for Users --- This title will be used as the link text in the navigation sidebars of all documents unless you specify a different [`label`](#label) in the navigation section of a document. #### `label` If you want to change the way a document is listed in the navigation sidebar, you can use the `document` and `label` parameters like this: --- navigation: - document_one - document: document_two label: Customized Label for Document Two - document_three - document_four --- The `label` value defines how a document is shown in the document's sidebar navigation, even if the document to which it refers has its own [`title`](#title) parameter. The preceding example looks like this in the document's sidebar: ![The page document_two is listed as Customized Label for Document Two in the sidebar.](/static/looker/docs/images/dev-doc-navigation-label-2300.png) #### `section` If you want to break the navigation sidebar into sections, you can use the `section` parameter like this: --- navigation: - document_one - document_two - section: My Section Name - document_three - document_four --- In this example, the `section` parameter adds a section break and the text heading **My Section Name** to the sidebar. ![](/static/looker/docs/images/dev-doc-navigation-section-2206.png) The text heading is not a link itself; it does not refer to any of your document files. Data files ---------- Data files are [JSON](https://en.wikipedia.org/wiki/JSON) files with file extension `.json`, `.topojson`, or `.geojson`. The [`map_layer`](/looker/docs/reference/param-model-map-layer) parameter lets you use a JSON file as a custom map that can then be used to plot your data in Looker. ![](/static/looker/docs/images/data-lookml-ui-612-v2.png) You then use the [map\_layer\_name](/looker/docs/reference/param-field-map-layer-name) parameter with a dimension so that you can associate a data value (like "Paris") with a geographic region on your custom map. You can edit a JSON file in the LookML IDE and then select **Save**. For debugging, you can choose **View Raw** by [selecting the **See file actions** menu next to the name of the file](#viewing_the_document_outside_the_ide) to view the file in raw format. If you have the proper extension to view JSON in your browser, you will also have the option to view the file in a **Parsed** format. See the [Managing LookML files and folders](/looker/docs/creating-project-files#uploading_files) documentation page for instructions on uploading a JSON file to a LookML project. Project manifest files ---------------------- Your project may contain a project manifest file, which is used for the following tasks: * Specifying other projects to [import into the current project](/looker/docs/importing-projects) * Specifying [model localization settings](/looker/docs/model-localization) * Defining [LookML constants](/looker/docs/sql-and-referring-to-lookml#lookml_constants) * Adding an [extension](/looker/docs/intro-to-extension-framework#adding_an_extension_to_looker) to your project * Adding a [custom visualization](/looker/docs/reference/param-manifest-visualization) to your project Each project can only have one manifest file, and it must be named `manifest.lkml` and located at the root level of your project's directory structure and in your Git repository. See the [Managing LookML files and folders](/looker/docs/creating-project-files#creating_files) documentation page for instructions for creating LookML project files, including project manifest files. Manifest lock files ------------------- Manifest lock files are created automatically when a [remote dependency](/looker/docs/reference/param-manifest-remote-dependency) is added to the [project manifest file](#manifest_files) . Looker uses the manifest lock file to track the version of the remote projects that are specified in the manifest file. The manifest lock file is listed in the file browser panel of the Looker IDE and has the filename `manifest_lock.lkml`. Looker developers don't need to create or edit a manifest lock file, since lock files are managed automatically by Looker. For more information, see the [Importing files from other projects](/looker/docs/importing-projects#manifest_lock_file) documentation page. Locale strings files -------------------- If you are [localizing your data model](/looker/docs/model-localization) you will need to create locale strings files for each locale you want to localize to, including your default locale (for example, often English in the USA). Locale strings files list key-value pairs for each label and description that you are localizing in your model. The strings file for each locale should provide that locale's translation for each label or description. More information about creating locale strings files appears on the [Localizing your LookML model](/looker/docs/model-localization#creating_locale_strings_files) documentation page. See the [Managing LookML files and folders](/looker/docs/creating-project-files#creating_files) documentation page for instructions for creating LookML project files, including locale strings files. Explore files ------------- An [Explore](/looker/docs/lookml-terms-and-concepts#explore) is a [view](/looker/docs/lookml-terms-and-concepts#view) that users can query. An Explore is the starting point for a query or, in SQL terms, the `FROM` in a SQL statement. See the [Viewing and interacting with Explores in Looker](/looker/docs/viewing-and-interacting-with-explores) documentation page for information on how users interact with Explores to query your data. Explores are usually defined within a model file. However, sometimes you need a separate Explore file [for a derived table](/looker/docs/creating-ndts#using_includes_to_enable_referencing_fields) , or to [extend](/looker/docs/reference/param-explore-extends#extending_an_explore_across_models) or [refine](/looker/docs/lookml-refinements) an Explore across models. See the [Managing LookML files and folders](/looker/docs/creating-project-files#creating_files) documentation page for instructions for creating LookML project files, including Explore files. Data test files --------------- Your project may have [data test](/looker/docs/reference/param-model-test) files used for verifying the logic of your LookML model. Data tests can be contained in model files or in view files, but if your developers want to use the same data tests across several different models, it may be helpful to keep the data tests in their own, dedicated file. See the [Managing LookML files and folders](/looker/docs/creating-project-files#creating_files) documentation page for instructions for creating LookML project files, including data test files. Refinements files ----------------- Your project may have files used for [LookML refinements](/looker/docs/lookml-refinements) . With LookML refinements, you can adapt an existing [view](/looker/docs/reference/param-view-view) or [Explore](/looker/docs/reference/param-explore-explore) without editing the LookML file that contains it. LookML refinements can be contained in model, view, or Explore files, or in their own, dedicated file. See the [Managing LookML files and folders](/looker/docs/creating-project-files#creating_files) documentation page for instructions for creating LookML project files, including refinements files. Other files ----------- Many LookML elements can be housed in different files in your project, or in their own dedicated files. For example, [data tests](/looker/docs/reference/param-model-test) can be housed in model files, view files, or their own dedicated `.lkml` files. Send feedback Except as otherwise noted, the content of this page is licensed under the [Creative Commons Attribution 4.0 License](https://creativecommons.org/licenses/by/4.0/) , and code samples are licensed under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0) . For details, see the [Google Developers Site Policies](https://developers.google.com/site-policies) . Java is a registered trademark of Oracle and/or its affiliates. Last updated 2025-04-17 UTC. --- # LookML 对象的元数据  |  Looker  |  Google Cloud [跳至主要内容](#main-content) [![Google Cloud](https://www.gstatic.com/devrel-devsite/prod/v02f7c7b934487be255c5f28ebb00ed6c2fde7a607ac1d91773e0036b0a06ec31/cloud/images/cloud-logo.svg)](/) / * English * Deutsch * Español – América Latina * Français * Indonesia * Italiano * Português – Brasil * 中文 – 简体 * 日本語 * 한국어 [控制台](//console.cloud.google.com/?hl=zh-cn) 登录 * [Looker](https://cloud.google.com/looker?hl=zh-cn) [联系我们](https://cloud.google.com/contact?hl=zh-cn) [免费开始使用吧](//console.cloud.google.com/freetrial?hl=zh-cn) ![](https://cloud.google.com/_static/images/translated.svg?hl=zh-cn) 此页面由 [Cloud Translation API](//cloud.google.com/translate/?hl=zh-cn) 翻译。 * [Home](https://cloud.google.com/?hl=zh-cn) * [文档](https://cloud.google.com/docs?hl=zh-cn) * [Looker](https://cloud.google.com/looker?hl=zh-cn) * [Documentation](https://cloud.google.com/looker/docs?hl=zh-cn) * [指南](https://cloud.google.com/looker/docs/intro?hl=zh-cn) 发送反馈 LookML 对象的元数据 使用集合让一切井井有条 根据您的偏好保存内容并对其进行分类。 =============================================== 拥有 [`develop`](https://cloud.google.com/looker/docs/admin-panel-users-roles?hl=zh-cn#develop) 权限的用户可以在 Looker IDE 元数据面板中查看与对象相关的上下文信息。 如需在 Looker IDE 中查看元数据面板,请执行以下操作: ![](https://cloud.google.com/static/looker/docs/images/dev-metadata-2120.png?hl=zh-cn) 1. [前往您的项目文件](https://cloud.google.com/looker/docs/accessing-project-files?hl=zh-cn) 。 2. 如需打开“快捷帮助”面板,请选择**快捷帮助**图标 info。 3. 在 LookML 代码编辑器中,将光标放在元数据面板中您想要了解更多背景信息的对象上。 4. 在快捷帮助面板中,选择**元数据**标签页以打开元数据面板。 元数据面板会使用名称和表示对象类型的图标来标识对象(如需查看所有可能的对象类型图标,请参阅[使用对象浏览器面板浏览项目](https://cloud.google.com/looker/docs/object-browser?hl=zh-cn#icons) 文档页面)。 如果一个 LookML 对象在多个模型中使用,元数据面板会提供一个下拉菜单,以便您选择要查看元数据的模型。 元数据面板中显示的信息取决于您选择的 LookML 对象的类型,以及所选对象在项目中的使用方式。您可以使用元数据更好地了解项目的许多方面,如以下部分所述。 模型的元数据 ------ 如果您选择模型文件,元数据面板会显示以下部分: * **信息中心**:列出模型中包含的所有 LookML 信息中心,以及指向 LookML 项目中相应定义的链接 * **探索**:列出模型中包含的所有探索,以及指向 LookML 项目中相应定义的链接 * **视图**:列出模型中包含的所有视图,以及指向 LookML 项目中相应定义的链接 每个部分的标题还会显示每种类型的对象的数量。 视图的元数据 ------ 如果您选择视图参数,元数据面板会显示有关视图在项目中的使用方式的以下信息: 1. **视图名称和详细信息**:视图名称和表示视图对象类型的图标(如需查看所有可能的对象类型图标,请参阅[使用对象浏览器面板浏览项目](https://cloud.google.com/looker/docs/object-browser?hl=zh-cn#icons) 文档页面)。元数据面板还会提供文件名以及文件的 LookML 中定义视图的行号(以及指向项目中视图的链接)。 2. **“已在 \[number\] 个模型中使用”菜单**:显示包含此视图的模型列表,其中 **\[number\]** 表示包含此视图的模型数量。例如,如果某个视图在两个模型中都使用过,元数据面板会显示“已在 2 个模型中使用”文本。 3. **主键**:视图的[主键](https://cloud.google.com/looker/docs/reference/param-field-primary-key?hl=zh-cn) 。 4. 基本视图:将此视图用作基本视图的探索。 5. **加入了**:探索此视图的[加入](https://cloud.google.com/looker/docs/working-with-joins?hl=zh-cn) 情况。 如果视图有[扩展](#extends) 或[优化](#refinements) ,这些内容也会显示在元数据面板中。 探索的元数据 ------ 如果您选择 `explore` 参数,元数据面板会显示有关“探索”在项目中的使用方式的以下信息: 1. **“探索”名称和详细信息**:“探索”名称和表示其对象类型的图标(如需查看所有可能的对象类型图标,请参阅[使用“对象浏览器”面板浏览项目](https://cloud.google.com/looker/docs/object-browser?hl=zh-cn#icons) 文档页面)。元数据面板还会提供文件的名称以及文件的 LookML 中定义探索的位置的行号(以及指向项目中探索的链接)。 2. **基本视图**:探索的基本视图(用于构建探索的起点)。 3. **联接的视图**:[联接](https://cloud.google.com/looker/docs/working-with-joins?hl=zh-cn) 到基准视图中的其他视图。 如果“探索”包含[扩展](#extends) 或[优化](#refinements) ,这些内容也会显示在元数据面板中。 字段的元数据 ------ 如果您选择某个[字段](https://cloud.google.com/looker/docs/reference/param-field?hl=zh-cn) ,元数据面板会显示有关该字段在项目中的使用方式的以下信息: 1. **字段名称和详细信息**:字段名称和表示其对象类型的图标(如需查看所有可能的对象类型图标,请参阅[使用对象浏览器面板浏览项目](https://cloud.google.com/looker/docs/object-browser?hl=zh-cn#icons) 文档页面)。元数据面板还会显示字段的类型,并提供文件名以及文件的 LookML 中定义该字段的行号(以及指向项目中该字段的链接)。 2. **Used in \[number\] models menu**:显示包含此字段的视图的模型列表。 3. **存在于视图中**:使用此字段的视图。 扩展程序的元数据 -------- 当您在 LookML 代码编辑器中选择 `view` 或 `explore` 参数时,元数据面板的“Extended by”(扩展)部分会显示该对象的所有[扩展](https://cloud.google.com/looker/docs/reusing-code-with-extends?hl=zh-cn) 。 例如,请考虑以下模型文件的 LookML 代码示例,其中 `aircraft_extended`“探索”扩展了 `aircraft`“探索”: explore: aircraft { view_name: aircraft join: aircraft_types { type: left_outer sql_on: ${aircraft.aircraft_type_id} = ${aircraft_types.aircraft_type_id} ;; relationship: many_to_one } join: aircraft_engine_types { type: left_outer sql_on: ${aircraft.aircraft_engine_type_id} = ${aircraft_engine_types.aircraft_engine_type_id} ;; relationship: many_to_one } } explore: aircraft_extended { extends: [aircraft] label: "Aircraft Extended" } 如果您为 `aircraft`“探索”部分选择了 LookML 定义,元数据面板的**扩展**部分会列出 `aircraft_extended`。点击**扩展**部分中的链接,即可直接前往定义了 `aircraft_extended` 的 LookML。 如果您点击 `aircraft_extended`“探索”的定义,元数据面板会提供有关扩展的 `aircraft`“探索”的以下信息: * **已联接的视图**:列出已联接到`aircraft`“探索”的所有视图。 * **扩展**:列出所选探索所扩展的对象。在本例中,这是 `aircraft`“探索”。 在这些示例中,扩展的 `explore` 参数和被扩展的 `explore` 参数位于同一文件中相邻的位置,但情况并不总是如此。从参数上看,很难看出它是否已扩展,尤其是因为被扩展的对象和扩展对象可能位于不同的 LookML 文件中。无论相关对象是在何处定义的,元数据面板都会为您提供相关对象的上下文。 精炼项的元数据 ------- 借助元数据面板,您可以轻松查看何时有视图或探索对象添加了[优化](https://cloud.google.com/looker/docs/lookml-refinements?hl=zh-cn) 。元数据面板的**优化**部分会显示已添加到对象的优化数量,您可以使用相应链接前往每个优化的 LookML。 与扩展程序一样,您无法仅通过查看 LookML 就确定对象是否经过了优化,尤其是因为优化后的 LookML 可能位于其他文件中。通过元数据面板,您可以查看对象是否已过精炼,如果已过精炼,则可以直接前往 LookML 进行精炼。 导入的项目的元数据 --------- 元数据面板包含[导入的项目](https://cloud.google.com/looker/docs/importing-projects?hl=zh-cn) 中的对象的相关信息,包括用于导航到定义对象的导入文件的链接。例如,为基于导入的视图文件的探索选择 LookML 后,元数据面板中会显示导入的视图文件的信息。 在元数据面板中,您可以点击链接,前往定义该对象的导入文件。 此外,您还可以点击 IDE 文件浏览器中[“导入的项目”文件夹](https://cloud.google.com/looker/docs/ide-folders?hl=zh-cn#imported_projects_folder) 中的对象,查看导入文件的元数据。 发送反馈 如未另行说明,那么本页面中的内容已根据[知识共享署名 4.0 许可](https://creativecommons.org/licenses/by/4.0/) 获得了许可,并且代码示例已根据 [Apache 2.0 许可](https://www.apache.org/licenses/LICENSE-2.0) 获得了许可。有关详情,请参阅 [Google 开发者网站政策](https://developers.google.com/site-policies?hl=zh-cn) 。Java 是 Oracle 和/或其关联公司的注册商标。 最后更新时间 (UTC):2025-04-22。 --- # Using the LookML Diagram  |  Looker  |  Google Cloud [Skip to main content](#main-content) [![Google Cloud](https://www.gstatic.com/devrel-devsite/prod/v02f7c7b934487be255c5f28ebb00ed6c2fde7a607ac1d91773e0036b0a06ec31/cloud/images/cloud-logo.svg)](/) / * English * Deutsch * Español – América Latina * Français * Indonesia * Italiano * Português – Brasil * 中文 – 简体 * 日本語 * 한국어 [Console](//console.cloud.google.com/) Sign in * [Looker](https://cloud.google.com/looker) [Contact Us](https://cloud.google.com/contact) [Start free](//console.cloud.google.com/freetrial) * [Home](https://cloud.google.com/) * [Looker](https://cloud.google.com/looker) * [Documentation](https://cloud.google.com/looker/docs) * [Guides](https://cloud.google.com/looker/docs/intro) Send feedback Using the LookML Diagram Stay organized with collections Save and categorize content based on your preferences. ================================================================================================================== The LookML Diagram is an extension — a web application built using Looker components — developed using the Looker [extension framework](/looker/docs/intro-to-extension-framework) and deployed through the [Looker Marketplace](/looker/docs/marketplace) . The LookML Diagram is an entity-relationship diagram of a LookML model that visually depicts relationships between its [LookML objects](/looker/docs/glossary#lookml-object) . Use this extension to: * Assess the structure of the LookML model, identifying areas where LookML can be consolidated and determining how best to add to the model * Identify incorrect logic, reducing the chances of incorrect calculations and poor query performance * Learn how to do code-based (LookML) data modeling This documentation page describes how to use the LookML Diagram version 2.0.0. and later. Looker admins should refer to the [Configuring the LookML Diagram extension](/looker/docs/lookml-diagram-configuring) documentation page for instructions on how to enable this extension for Looker users. This page discusses how to: * [Navigate to the LookML Diagram](#navigating_to_the_lookml_diagram) * [Observe LookML object relationships with the LookML Diagram](#observing_lookml_object_relationships_with_the_lookml_diagram) * [Configure diagram settings](#configuring_diagram_settings) * [Configure view options for an Explore](#explore_viewing_options) * [Interpret the diagram canvas](#interpreting_the_diagram_canvas) * [Observe object information with the Object Profiler](#viewing_object_information_with_the_object_profiler) Navigating to the LookML Diagram -------------------------------- After the LookML Diagram has been installed, you can navigate to the LookML Diagram by clicking **Blocks** in the left navigation panel and then selecting the **LookML Diagram** tile. ![](/static/looker/docs/images/access-lookml-diagram-2214.png) Observing LookML object relationships with the LookML Diagram ------------------------------------------------------------- Your Looker admin must grant you [permissions](/looker/docs/lookml-diagram-configuring#granting_permissions_to_use_the_lookml_diagram) to the `lookml_diagram` model and any model that you want to view in the extension. The LookML Diagram extension consists of these elements: ![](/static/looker/docs/images/marketplace-extensions-lookml-diagram-ui-v200-718.png) 1. A **Diagram Settings** panel to select a [model](/looker/docs/lookml-terms-and-concepts#model) , a [Git branch](/looker/docs/version-control-and-deploying-changes#working_with_git_branches) , and an [Explore](/looker/docs/lookml-terms-and-concepts#explore) 2. A **View Options** panel to refine which fields you would like to view 3. A **Diagram Help** section to provide additional explanation of the diagram elements 4. A diagram canvas to interact with the LookML objects in the selected Explore 5. A selected Explore's list of [fields](/looker/docs/lookml-terms-and-concepts#field) , grouped by [view](/looker/docs/lookml-terms-and-concepts#view) 6. A toolbar with zoom and position options and an icon to show or hide the canvas minimap, which helps to orient yourself within a larger diagram 7. A Object Profiler to view information about the [LookML object](/looker/docs/glossary#lookml-object) and navigate to its associated LookML or Explore, if applicable Double-click either the **Diagram Settings** icon or the **View Options** icon to collapse the left panel. Configuring diagram settings ---------------------------- Click the diagram icon in the diagram navigation bar to display **Diagram Settings**. The **Choose a Model** drop-down lists all the models for which you have [permissions](/looker/docs/lookml-diagram-configuring#granting_permissions_to_use_the_lookml_diagram) to view. Once you've selected a model, two additional options appear: * The **Current Branch** drop-down populates with a list of that model's [Git branches](/looker/docs/version-control-and-deploying-changes#working_with_git_branches) . If the model has only one branch — usually the [production branch](/looker/docs/version-control-and-deploying-changes#working_with_git_branches) — that branch is displayed. If you are in Production Mode or if you do not have [permissions to change Git branches](/looker/docs/lookml-diagram-configuring#granting_permissions_to_use_the_lookml_diagram) , the **Current Branch** drop-down menu is disabled. If your admin has granted you permissions to change Git branches on the LookML Diagram, turn on Development Mode, ensure that both a model and an Explore are selected, and then select a branch to view the diagram according to how the model is set up on that branch. * The **Select an Explore** list populates with a list of that model's Explores. Click on the name of an Explore to see its fields, grouped by view, displayed on the page canvas. Explore viewing options ----------------------- With an Explore selected, you can use the **View Options** panel to restrict which fields and views are displayed on the canvas. ### Limiting displayed fields You can choose to display all fields in each view of the Explore by selecting **All fields** under **Fields to Display**; or, to show only the views that have fields joined to other fields, select **Fields with joins**. If enabled, the **Hide hidden fields** toggle hides any field that [contains `hidden: yes`](/looker/docs/reference/param-field-hidden) in its underlying LookML. The **Hide hidden fields** toggle is enabled by default. ### Limiting displayed views The **Views** section of the **View Options** panel shows a list of the views present in the selected Explore. By default, all views are displayed on the diagram canvas. When you hide a view, the view object and any joins that connect that view object to any other objects in the Explore are hidden from the diagram canvas. Click **Hide all** to hide all the views in the Explore from the diagram canvas. Click **Show all** to unhide all views in that Explore. You can also selectively hide individual views from the canvas by de-selecting the eye icon to the right of the view name. When the view is hidden, the view name appears grayed out and the eye icon has a slash through it. To unhide an individual hidden view, click the slashed-eye icon. Interpreting the diagram canvas ------------------------------- The LookML Diagram canvas is where all entities and relationships for a given Explore are depicted. In the Looker vernacular you can think of the LookML Diagram as depicting how [LookML objects](/looker/docs/glossary#lookml-object) are [joined](/looker/docs/working-with-joins) together in an Explore for a given model. The object title bar across the top of the canvas displays the name of the Explore whose views are displayed on the canvas. Click the Explore info icon — an encircled "i" — in the object title bar to open the [Object Profiler](#viewing_object_information_with_the_object_profiler) and learn more about the selected Explore. Click the clockwise arrow to reload the extension. ### Entities Each view of the Explore is represented as its own entity set, with the view name appearing at the top of the set: ![](/static/looker/docs/images/marketplace-extensions-lookml-diagram-canvas-v200-718.png) 1. The Explore's [base view](/looker/docs/glossary#base-view) is indicated by a dark blue background. 2. Joined views in the Explore have a light blue background. 3. When a join, view, or field is selected, it is highlighted in a bright blue. Below each view is a list of fields belonging to that view: 4. Dimensions are listed at the top. 5. Measures are listed at the bottom and highlighted in light orange. 6. If the field is a [primary key](/looker/docs/reference/param-field-primary-key) , a key icon appears to the right of the field name. To the left of each field is an icon indicating its type: * **A**: dimensions of `type: string` * **#**: dimensions or measures of `type: number` * Tiered bars: dimensions of `type: tier` * Checkmark: dimensions of `type: yesno` * Calendar: dimensions of `type: date`, `type: date_time`, `type: time` * Map point: dimensions of `type: location`, `type: distance`, `type: zipcode` Click the field name to open the [Object Profiler](#viewing_object_information_with_the_object_profiler) and learn more about the selected field. ### Relationships The diagram uses a line to depict how each object relates to other object in the selected model. The shape of the line, where it attaches to the view or field, conveys the cardinality of the relationship between the two objects; a forked line indicates a "many" cardinality, and a single line indicates a "one" cardinality. You would read the relationship as _from_ the base view _to_ the joined view. For example: ![](/static/looker/docs/images/marketplace-extensions-lookml-diagram-joins-v200-718.png) 1. A one-to-one join from `order_items` to `inventory_items`, joining on the `id` field 2. A many-to-one join from `order_items` to `repeat_purchase_facts` You can also hover over the line to see what [type of join](/looker/docs/working-with-joins) relationship connects the two objects. Click the line to open the [Object Profiler](#viewing_object_information_with_the_object_profiler) to view more information about the join. ### Canvas viewing options A minimap in the upper right of the canvas can help orient your placement within larger diagrams, with the grayed out portion of the map indicating what portion of the diagram is currently displayed on the canvas. Click and drag the empty space in the canvas to move to other parts of the diagram. A vertical toolbar in the lower left of the canvas contains icons to control the diagram display: ![](/static/looker/docs/images/marketplace-extensions-lookml-diagram-zoom-v200-718.png) * Click the (**+**) to zoom in and the (**\-**) to zoom out of the diagram. * Click the square icon to return to the default starting position of the diagram. * Click the map icon to enable or disable the minimap. Viewing object information with the Object Profiler --------------------------------------------------- The Object Profiler displays information about the selected object. Click on any Explore, view, field, or join on the diagram canvas to open the Object Profiler on the right side of the canvas. Click the canvas to collapse the Object Profiler. ### Explores Click on the Explore info icon — an encircled "i" — on the right side of the object title bar. For the Explore selected in the **Diagram Settings** panel, the Object Profiler displays: * **Label**: The value of the [Explore `label`](/looker/docs/reference/param-explore-label) . * **Group Label**: The value of the [`group_label`](/looker/docs/reference/param-explore-group-label) parameter, which combines Explores into custom groups in the **Explore** menu of Looker. If a group label is not defined for the Explore, this defaults to the name of the model. * **Project Name**: The name of the LookML [project](/looker/docs/lookml-project-files) , as defined in the [project settings](/looker/docs/git-options#project_settings) . * **Connection Name**: The value of the [`connection`](/looker/docs/reference/param-model-connection) parameter, which specifies the database connection from which a model will retrieve data. If you have permissions to view LookML, you can click **Go to LookML** at the bottom left of the Object Profiler to open the file where the Explore is defined. The file opens in a new browser tab with the line for the `explore` highlighted. ### Views Click on a view from the diagram canvas. The Object Profiler displays the **SQL Table Name** if defined in the view's LookML. If no [`sql_table_name`](/looker/docs/reference/param-view-sql-table-name) is defined for the view, the **SQL Table Name** is shown as `unknown`. If you have permissions to view LookML, you can click **Go to LookML** at the bottom left of the Object Profiler to open the file where the Explore to which the view is joined is defined. The file opens in a new browser tab with the line for the `explore` highlighted. ### Fields Click on a field from the diagram canvas. The Object Profiler displays the field name, type, and type value, and whether the field is a [primary key](/looker/docs/reference/param-field-primary-key) at the top of the panel. Two tabs in the profiler — **Details** and **Code** — show additional information about the field. In the **Details** tab, you can view: * **View Name**: The name of the view to which the field belongs. * **Label**: How the field will appear in the Data section of an Explore, which is the name or [label](/looker/docs/reference/param-view-label) of the view followed by the name or [label](/looker/docs/reference/param-field-label) of the field. * **Distribution**: For numeric dimensions on a view with a measure that has `type: count`, click **Calculate** to show a preview of a column chart depicting the distribution of the count values. The **Distribution** section will also display the minimum, maximum, and average values of the numeric dimension series. * **Values**: For numeric dimensions on a view with a measure that has `type: count`, click **Calculate** to show a preview of count values. Click **Explore More** to open the Explore to which this field belongs. In the **Code** tab, you can view the [field parameter and subparameters](/looker/docs/reference/param-field) . If you have permissions to view LookML, you can click **Go to LookML** at the bottom left of the Object Profiler to open the file where the join is defined. The file opens in a new browser tab at the line for the join's Explore. If you have permissions to explore data, click **Explore with Field** at the bottom right of the Object Profiler to open an Explore with that field pre-selected in the Explore field picker. ### Joins Click on a join from the diagram canvas. The Object Profiler displays the [join statement](/looker/docs/reference/param-explore-join) that describes the join relationship and the [type](/looker/docs/working-with-joins) and [cardinality](/looker/docs/reference/param-explore-join-relationship) of the join. If you have permissions to view LookML, you can click **Go to LookML** at the bottom left of the Object Profiler to open the file where the join is defined. The file opens in a new browser tab at the line for the join's Explore. Send feedback Except as otherwise noted, the content of this page is licensed under the [Creative Commons Attribution 4.0 License](https://creativecommons.org/licenses/by/4.0/) , and code samples are licensed under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0) . For details, see the [Google Developers Site Policies](https://developers.google.com/site-policies) . Java is a registered trademark of Oracle and/or its affiliates. Last updated 2025-02-06 UTC. --- # LookML 优化  |  Looker  |  Google Cloud [跳至主要内容](#main-content) [![Google Cloud](https://www.gstatic.com/devrel-devsite/prod/v02f7c7b934487be255c5f28ebb00ed6c2fde7a607ac1d91773e0036b0a06ec31/cloud/images/cloud-logo.svg)](/) / * English * Deutsch * Español – América Latina * Français * Indonesia * Italiano * Português – Brasil * 中文 – 简体 * 日本語 * 한국어 [控制台](//console.cloud.google.com/?hl=zh-cn) 登录 * [Looker](https://cloud.google.com/looker?hl=zh-cn) [联系我们](https://cloud.google.com/contact?hl=zh-cn) [免费开始使用吧](//console.cloud.google.com/freetrial?hl=zh-cn) ![](https://cloud.google.com/_static/images/translated.svg?hl=zh-cn) 此页面由 [Cloud Translation API](//cloud.google.com/translate/?hl=zh-cn) 翻译。 * [Home](https://cloud.google.com/?hl=zh-cn) * [文档](https://cloud.google.com/docs?hl=zh-cn) * [Looker](https://cloud.google.com/looker?hl=zh-cn) * [Documentation](https://cloud.google.com/looker/docs?hl=zh-cn) * [指南](https://cloud.google.com/looker/docs/intro?hl=zh-cn) 发送反馈 LookML 优化 使用集合让一切井井有条 根据您的偏好保存内容并对其进行分类。 =========================================== 概览 -- 借助 LookML 优化功能,您无需修改包含相应视图或探索的 LookML 文件,即可调整现有[视图](https://cloud.google.com/looker/docs/reference/param-view-view?hl=zh-cn) 或[探索](https://cloud.google.com/looker/docs/reference/param-explore-explore?hl=zh-cn) 。这非常适用于以下情况: * 包含 [Looker 块](https://cloud.google.com/looker/docs/blocks?hl=zh-cn) 的项目,这些块使用预构建的 LookML 部分 * [从其他项目导入文件](https://cloud.google.com/looker/docs/importing-projects?hl=zh-cn) 的项目 * 您经常需要[根据数据库中的表生成文件](https://cloud.google.com/looker/docs/generating-a-model?hl=zh-cn) 的项目 * 您希望在模型或项目之间共享 LookML,同时在每个位置进行自定义(枢纽和辐条配置) 例如,如果您的项目中有以下 View 文件: view: flights { sql_table_name: flightstats.accidents ;; dimension: id { label: "id" primary_key: yes type: number sql: ${TABLE}.id ;; } } 您可以优化 `flights` 视图,如以下示例所示:使用与视图名称相同的 `view` 参数,但在名称前面添加加号 (`+`) 以指明它是对现有视图的优化。 此优化会向现有的 `flights` 视图添加 `air_carrier` 维度: view: +flights { dimension: air_carrier { type: string sql: ${TABLE}.air_carrier ;; } } 此优化可添加到项目中的任何 LookML 文件中,例如模型文件、视图文件,或添加到自己的专用 LookML 文件中。如需了解其运作方式,请参阅[在 LookML 项目中使用优化](#using_refinements_in_your_lookml_project) 部分。 优化后的 LookML 与原始 LookML 结合使用,最终结果就如同该视图的原始 LookML 一样: view: flights { sql_table_name: flightstats.accidents ;; dimension: id { label: "id" primary_key: yes type: number sql: ${TABLE}.id ;; } dimension: air_carrier { type: string sql: ${TABLE}.air_carrier ;; } } 在 Looker 界面中,用户会看到**航空公司**维度,就像您将该维度添加到原始视图文件本身一样。 如需了解更详细的实现信息,请参阅[示例](#example) 部分。 ### 优化与扩展的比较 Looker 还支持[扩展](https://cloud.google.com/looker/docs/reusing-code-with-extends?hl=zh-cn) LookML 对象。当您想要创建现有视图或探索的新副本,以便向其中添加新对象时,扩展功能非常有用。例如,您可以创建一个用于定义所有字段的基础视图,然后创建多个用于扩展基础视图的新视图。然后,您可以修改这些新视图,以隐藏基视图中的某些字段,或更改基视图中字段的定义或标签。 如果您想修改现有视图或探索,通过对某些对象进行调整或微调,但不想创建视图或探索的副本,那么精炼功能非常有用。如果您无法或不想修改基本视图或“探索”,或者创建新视图或“探索”需要对其他 LookML 参考进行大量更改,则非常适合使用“优化”。如需查看此用例的示例,请参阅本页的[示例](#example) 部分。 对于大多数用例,优化是 `extends` 的更简单、更清晰的替代方案。 高级 LookML 开发者可能需要在 LookML 精确化中使用 [`extends`](https://cloud.google.com/looker/docs/reusing-code-with-extends?hl=zh-cn) 参数。如需了解详情,请参阅本页的[精炼项可以包含 extends](#refinements_can_contain_extends) 部分。 ### 优化会替换大多数参数 请务必注意,在大多数情况下,优化设置会替换对象的原始设置。在以下示例中,原始视图有一个隐藏的维度 (`hidden: yes`): view: faa_flights { dimension: carrier { hidden: yes } } 在另一个文件中,使用 `hidden: no` 对该维度进行了优化: include: "/views/faa_flights.view.lkml" view: +faa_flights { dimension: carrier { hidden: no } } 最后的优化会优先应用,因此系统会应用 `hidden: no`,并且该维度将显示在最终视图中。 在某些情况下,优化是_累加_的,而不是替换的;如需了解详情,请参阅本页的[部分参数是累加的](#some_parameters_are_additive) 部分。 ### 某些参数是累加的 在许多情况下,如果精炼项包含与要精炼的对象相同的参数,[精炼项将替换精炼对象的参数值](#refinements_override_parameters) 。 但对于某些参数,精炼项可以是_叠加_的,也就是说,基础对象中的值会与经过精炼的对象中的值结合使用。 以下参数是_累加_的: * 对于维度和测量: * [`action`](https://cloud.google.com/looker/docs/reference/param-field-action?hl=zh-cn) * [`filters`](https://cloud.google.com/looker/docs/reference/param-field-filters?hl=zh-cn) * [`link`](https://cloud.google.com/looker/docs/reference/param-field-link?hl=zh-cn) * 对于参数: * [`allowed_value`](https://cloud.google.com/looker/docs/reference/param-field-parameter?hl=zh-cn#specifying_allowed_values) * 对于派生表: * [`bind_filters`](https://cloud.google.com/looker/docs/reference/param-view-explore-source?hl=zh-cn#bind_filters_example) * [`dev_filters`](https://cloud.google.com/looker/docs/reference/param-view-explore-source?hl=zh-cn#dev_filters) * [`filters`](https://cloud.google.com/looker/docs/reference/param-view-explore-source?hl=zh-cn#filters) * [`sorts`](https://cloud.google.com/looker/docs/reference/param-view-explore-source?hl=zh-cn#sorts) * 对于观看: * [`extends`](https://cloud.google.com/looker/docs/reference/param-view-extends?hl=zh-cn) (如需了解详情,请参阅本页的[精炼 `extends` 是累加的](#additive) 部分。) * 对于探索: * [`access_filter`](https://cloud.google.com/looker/docs/reference/param-explore-access-filter?hl=zh-cn) * [`aggregate_table`](https://cloud.google.com/looker/docs/reference/param-explore-aggregate-table?hl=zh-cn) * [`extends`](https://cloud.google.com/looker/docs/reference/param-explore-extends?hl=zh-cn) (如需了解详情,请参阅本页的[精炼 `extends` 是累加的](#additive) 部分。) * [`join`](https://cloud.google.com/looker/docs/reference/param-explore-join?hl=zh-cn) * [`query`](https://cloud.google.com/looker/docs/reference/param-explore-query?hl=zh-cn) 例如,下面是一个具有 `name` 尺寸和 `link` 参数的视图: 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" } } } 下面是对 `carriers` 视图的优化,其中 `name` 维度具有不同的 `link` 参数值: include: "/views/carriers.view.lkml" view: +carriers { label: "Refined 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" } } } 在经过优化的 `carriers` 视图中,两个 `link` 参数是累加的,因此 `name` 维度将显示这两个链接。 ![](https://cloud.google.com/static/looker/docs/images/dev-refinements-additive-links-2114.png?hl=zh-cn) ### 优化按顺序应用 一个对象可以在多个位置多次进行优化,这让 Looker 开发者可以以许多富有创意的方式使用优化功能。但这也意味着,开发者必须非常注意优化应用的顺序: * 在项目中,系统会按照包含其文件的顺序应用优化。最后包含的文件中的优化设置会覆盖先前包含的文件中的优化设置。 * 在单个文件中,优化会从上往下逐行应用。行号最高的优化项会最后应用,并且会覆盖任何较早的优化项(如果存在冲突)。 例如,在以下视图文件中,`faa_flights` 视图有两个精炼项。第一个精细化会隐藏维度 (`hidden: yes`),而第二个精细化会显示维度 (`hidden: no`)。如果出现此类冲突,文件中位于最底部的细化会优先: include: "//e_faa_original/views/faa_flights.view.lkml" view: +faa_flights { dimension: carrier { hidden: yes } } view: +faa_flights { dimension: carrier { hidden: no } } 在项目中包含多个文件的逻辑类似:包含项中列出的最后一个文件中的优化将优先。例如,如果模型文件包含以下文件: include: "/refinements/distance_analysis.lkml" include: "/refinements/finishing_touches.lkml" 系统会先应用 `distance_analysis.lkml` 中的所有优化,然后再应用 `finishing_touches.lkml` 文件中的所有优化。如果存在任何冲突,最后一个文件 `finishing_touches.lkml` 中的优化设置将优先。 ### 使用 `final: yes` 来阻止进一步优化 如前所述,同一对象可以在多个位置多次进行优化,并且[最后一次优化](#order) 将[替换](#overrides) 所有之前的优化。 如果您希望某个精炼项被视为相应视图或“探索”的最终精炼项,可以向该精炼项添加 `final: yes` 标志。如果有现有优化标签会在最终优化标签应用后应用,或者开发者尝试添加会在最终优化标签应用后应用的新优化标签,Looker IDE 将返回 LookML 错误。例如,此视图文件中的第二个优化会导致 LookML 错误,因为上一个优化具有 `final: yes` 标志: include: "//e_faa_original/views/faa_flights.view.lkml" view: +faa_flights { final: yes dimension: carrier { hidden: yes } } view: +faa_flights { dimension: carrier { hidden: no } } 向精确化添加 `final: yes` 标志是一种很好的方式,可验证精确化是否按预期顺序应用。 ### 精炼可以包含扩展 高级 LookML 开发者可能需要在 LookML 精炼中使用 `extends` 参数,以将扩展对象添加到要精炼的对象。 `extends` 和优化功能的行为总结如下: * 扩展对象会创建该对象的新副本,然后在此基础上进行构建。例如,您可以创建一个用于定义所有字段的基础视图,然后创建多个用于扩展基础视图的新视图。这些新视图中的每个视图都会包含基准视图的副本,开发者可以在此基础上添加不同的字段、过滤条件或其他属性,以修改基准视图中的内容。基本思路是,您先创建一个基对象,然后在多个其他对象中以不同的方式使用该对象。(如需详细了解如何使用 extends,请参阅[使用 extends 重复使用代码](https://cloud.google.com/looker/docs/reusing-code-with-extends?hl=zh-cn) 文档页面。) * 对对象进行精炼会为对象添加一层修改,但与扩展不同,精炼不会创建对象的多个副本。其基本思路是,在不修改其原始 LookML 的情况下,基于基准对象进行构建。 下面是一个名为 `orders` 的探索以及对其进行细化的 `+orders` 探索,展示了标准的细化使用方式: explore: orders { view_name: orders # other Explore parameters } explore: +orders { label: "Orders Information" # other Explore parameters to build on the original Explore } 此外,您还可以添加包含 `extends` 的精确化条件。接着上例,下面是相同的 `orders` 探索。除此之外,还有一个名为 `users_base` 的基础探索,现在 `+orders` 精炼项有一个 `extends` 参数,用于引入 `users_base`: explore: users_base { view_name: users extension: required # other Explore parameters } explore: orders { view_name: orders # other Explore parameters } explore: +orders { label: "Orders Information" extends: [users_base] # other Explore parameters to build on the original Explore } 这里的特殊之处在于,`+orders` 精炼中包含 `extends`。结果是,`+orders` 视图现在会展开 `users_base`“探索”。 #### Looker 如何在优化中实现 `extends` 在精炼项中扩展对象是一项高级 LookML 概念。在精炼中使用 `extends` 之前,您应对以下内容有深刻的理解: * Looker 如何实现 `extends`:如果在扩展_对象_和扩展_器对象_中都定义了 LookML 元素,则使用扩展对象中的版本,除非参数是[累加](https://cloud.google.com/looker/docs/reusing-code-with-extends?hl=zh-cn#some_parameters_are_additive) 。如需了解详情,请参阅[使用“extends”重复使用代码](https://cloud.google.com/looker/docs/reusing-code-with-extends?hl=zh-cn#implementation_details_for_extends) 文档页面。 * Looker 如何实现精炼:如果某个 LookML 元素在多个精炼中定义,则最后一个精炼会替换之前的精炼。如需了解详情,请参阅本页中的[优化会按顺序应用](#order) 部分。 最后,您应该了解 Looker 如何结合这些原则来实现用于优化的 `extends`。下面是 Looker 实现的顺序,如果发生冲突,每一步都会替换之前的步骤: 1. 对象中指定的 `extends` 中的值 2. 对象的优化项中指定的 `extends` 中的值 3. 对象中的值 4. 对象的细化值 下面的示例展示了在实现的每个步骤中跟踪 `label` 参数的值: explore: orders_base { label: "Orders Base" view_name: orders extension: required } explore: users_base { label: "Users Base" view_name: users extension: required } explore: orders { label: "Orders" extends: [orders_base] } explore: +orders { label: "Orders Refined" extends: [users_base] } 下面是此示例中 Looker 如何为 `orders`“探索”实现 `label` 值: 1. **对象中指定的 `extends` 中的值。**由于 `orders`“探索”具有 `extends` 参数,因此 Looker 会从要扩展的对象(在本例中为 `orders_base`“探索”)中的 LookML 元素开始。此时,`label` 值为“Orders Base”。 2. **对象的优化项中指定的 `extends` 中的值。**由于 `orders` 具有精确化条件,并且精确化条件具有 `extends` 参数,因此 Looker 会应用精确化条件扩展程序中的 LookML 元素,在本例中为 `users_base`“探索”部分。此时,`label` 值为“用户群”。 3. **对象中的值。**现在,所有扩展程序都已处理完毕,Looker 会应用扩展对象(在本例中为 `orders`“探索”)中的元素。如果存在任何冲突,扩展对象将优先。现在,`label` 的值为“Orders”。 4. **对象的优化值。**最后,Looker 会应用 `orders`“探索”的任何优化中的元素。如果存在任何冲突,则优先使用精炼对象。现在,`label` 的值为“Orders Refined”。 #### 优化 `extends` 是累加的 如本页的[优化项会替换参数](#refinements_override_parameters) 部分所述,优化项通常会替换对象的原始设置。`extends` 参数并非如此。在精炼中使用 `extends` 时,`extends` 参数中的值会附加到原始对象或之前的精炼(如果有)中扩展的项列表。然后,如果存在任何冲突,则优先级为扩展链中的最后一个项。 例如,下面是一个名为 `orders_base` 的基础探索,以及一个扩展该基础的 `orders` 探索。此外,还有 `users_base`“探索”和扩展 `users_base` 的 `+orders` 优化: explore: orders_base { view_name: orders extension: required # other Explore parameters } explore: users_base { view_name: users extension: required # other Explore parameters } explore: orders { extends: [orders_base] # other Explore parameters to build on the base Explore } explore: +orders { extends: [users_base] # other Explore parameters to build on the base Explores } `orders`“探索”会扩展 `orders_base`,然后 `+orders` 精确化操作会将 `users_base` 添加到 `extends` 列表。结果是,`+orders`“探索”现在将同时扩展 `orders_base` 和 `users_base`,就像这是“探索”的原始 LookML 一样: explore: orders { extends: [orders_base, users_base] } 然后,如果存在任何冲突,则优先级为扩展链中的最后一个项。在此示例中,`users_base` 中的元素会替换 `orders_base` 中的任何冲突元素。 如需了解一次扩展多个对象的概念,请参阅[使用 extends 重复使用代码](https://cloud.google.com/looker/docs/reusing-code-with-extends?hl=zh-cn#extending_more_than_one_object_at_the_same_time) 文档页面。 最后需要注意的是:在此示例中,`explore` 参数的顺序无关紧要。但是,如果同一对象有多个精确化,精确化的顺序很重要。如本页中的[优化会按顺序应用](#order) 部分所述,文件中的最后一个优化会覆盖之前的优化。 在 LookML 项目中使用精炼 ---------------- 以下是优化项目中视图和探索的大致步骤: 1. 确定您要优化的视图或“探索”页面。 2. 确定要将优化项存储在何处。您可以在任何现有 LookML 文件中添加精炼条件,也可以为精炼条件创建单独的 LookML 文件。(如需查看创建通用 LookML 文件的示例,请参阅**了解其他项目文件**文档页面上的[创建数据测试文件](https://cloud.google.com/looker/docs/other-project-files?hl=zh-cn#creating_data_test_files) 部分。) 3. 使用 [`include`](https://cloud.google.com/looker/docs/reference/param-model-include?hl=zh-cn) 参数将优化结果纳入模型: * 在您编写优化项的文件中,必须包含要优化的 LookML 文件。如果您尝试优化未包含的对象,Looker IDE 会向您发出警告。 * 在模型文件中,添加定义了优化的文件。您可以非常有创意地组合文件并使用包含项;如需了解详情,请参阅本页中的[使用优化项向模型添加层](#layers) 部分。 示例 -- 优化 LookML 对象是一种简单的方法,可让您调整视图和探索,而无需修改原始 LookML。如果您的项目中的视图和探索是只读的(例如[从其他项目导入的文件](https://cloud.google.com/looker/docs/importing-projects?hl=zh-cn) ),此功能会特别有用。下面是一个优化探索的示例。 以下是 `aircraft`“探索”的 LookML: explore: aircraft { join: aircraft_types { type: left_outer sql_on: ${aircraft.id} = ${aircraft_types.id} ;; relationship: many_to_one } join: aircraft_engine_types { type: left_outer sql_on: ${aircraft.id} = ${aircraft_engine_types.id} ;; relationship: many_to_one } } 此“探索”页面包含多个视图,每个视图都包含多个维度。 现在,另一个名为 `e_faa_refined` 的 LookML 项目会导入 `aircraft`“探索”文件。在 `e_faa_refined` 项目中,您可以使用优化功能来大幅简化 `aircraft`“探索”功能。 由于 `aircraft`“探索”是一个导入的文件,因此您无法直接对其进行修改。不过,您可以为其添加精确化条件。下面是一个名为 `refinements.lkml` 的单独文件示例,其中包含此 LookML: include: "//e_faa_original/Explores/aircraft.explore.lkml" explore: +aircraft { label: "Aircraft Simplified" fields: [aircraft.aircraft_serial, aircraft.name, aircraft.count] } `refinements.lkml` 文件包含以下内容: * `include` 参数,用于从导入的项目中引入原始 `aircraft.explore.lkml` 文件(如需详细了解如何引用导入的项目文件,请参阅[从其他项目导入文件](https://cloud.google.com/looker/docs/importing-projects?hl=zh-cn#referencing_files_from_an_imported_project) 文档页面)。 * `aircraft`“探索”部分的优化: * 探索名称前面的 `+` 符号表示对现有探索的优化。 * [`label`](https://cloud.google.com/looker/docs/reference/param-explore-label?hl=zh-cn) 参数会将“探索”的标签更改为“简化版飞机”。 * [`fields`](https://cloud.google.com/looker/docs/reference/param-explore-fields?hl=zh-cn) 参数指定“探索”中将仅显示三个字段。 最终结果看起来就像是原始的 `aircraft`“探索”和 `aircraft` 视图: explore: aircraft { label: "Aircraft Simplified" } view: aircraft { sql_table_name: flightstats.aircraft ;; dimension: aircraft_serial { type: string sql: ${TABLE}.aircraft_serial ;; } dimension: name { type: string sql: ${TABLE}.name ;; } measure: count { type: count } } 如需查看使用优化项针对多个用例自定义单个视图的示例,请参阅[使用 DRY LookML 最大限度提高代码可重用性:针对多个用例自定义单个基本视图](https://cloud.google.com/looker/docs/best-practices/dry-cookbook-5?hl=zh-cn) 实战宝典食谱。 其他优化用例 ------ 如前所述,优化非常适合调整只读 LookML 对象,例如 [Looker 块](https://cloud.google.com/looker/docs/blocks?hl=zh-cn) 或[导入的文件](https://cloud.google.com/looker/docs/importing-projects?hl=zh-cn) 。 不过,一旦您熟悉了如何添加精炼项并将其添加到模型中,就可以使用项目做出非常酷的事情,如以下示例所述。 ### 使用优化功能添加分析 您可以使用优化功能向模型添加分析,而无需更改原始 LookML 文件。例如,如果某个项目中的视图和探索是[从数据库中的表生成](https://cloud.google.com/looker/docs/generating-a-model?hl=zh-cn) 并存储在名为 `faa_basic.lkml` 的 LookML 文件中,您可以创建一个 `faa_analysis.lkml` 文件,并在其中使用精炼项添加分析。以下是一个名为 `distance_stats` 的新派生表的示例,其中包含距离分析。此示例展示了对 `faa_basic.lkml` 文件中现有 `flights` Explore 的优化,该优化会将 `distance_stats` 派生表联接到 `flights` Explore。此外,在示例底部,现有的 `flights` 视图经过优化,以便从分析中添加新字段: include: "faa_basic.lkml" explore: +flights { join: distance_stats { relationship: one_to_one type: cross } } view: distance_stats { derived_table: { explore_source: flights { bind_all_filters: yes column: distance_avg {field:flights.distance_avg} column: distance_stddev {field:flights.distance_stddev} } } dimension: avg { type:number sql: CAST(${TABLE}.distance_avg as INT64) ;; } dimension: stddev { type:number sql: CAST(${TABLE}.distance_stddev as INT64) ;; } } view: +flights { measure: distance_avg { type: average sql: ${distance} ;; } measure: distance_stddev { type: number sql: STDDEV(${distance}) ;; } dimension: distance_tiered2 { type: tier sql: ${distance} ;; tiers: [500,1300] } } ### 使用优化项向模型添加层 优化功能的另一个有趣用例是向项目添加图层。您可以创建多个优化文件,然后有策略地将其添加到图层中。 例如,在 FAA 项目中,有一个 `faa_raw.lkml` 文件,其中包含[从数据库中的表生成](https://cloud.google.com/looker/docs/generating-a-model?hl=zh-cn) 的所有视图和探索。此文件包含数据库中每个表的视图,每个视图都包含每个数据库列的维度。 除了原始文件之外,您还可以创建 `faa_basic.lkml` 文件,以添加包含基本优化的新图层,例如向探索添加联接,或向视图添加测量,如下所示: include: "faa_raw.lkml" explore: +flights { join: carriers { sql_on: ${flights.carrier} = ${carriers.name} ;; } } view: +flights { measure: total_seats { type: sum sql: ${aircraft_models.seats} ;; } } 然后,您可以添加 `faa_analysis.layer.lkml` 文件,以添加包含分析的新图层(如需查看分析文件示例,请参阅[使用优化项添加分析](#analysis) 子部分)。 然后,您只需将所有优化文件添加到模型文件中即可。您还可以使用模型文件添加精确化设置,将视图指向要引用的数据库表: connection: "publicdata_standard_sql" include: "faa_raw.lkml" include: "faa_basic.lkml" include: "faa_analysis.lkml" view: +flights { sql_table_name: lookerdata.faa.flights;; } view: +airports { sql_table_name: lookerdata.faa.airports;; } view: +aircraft { sql_table_name: lookerdata.faa.aircraft;; } view: +aircraft_models{ sql_table_name: lookerdata.faa.aircraft_models;; } view: +carriers { sql_table_name: lookerdata.faa.carriers;; } 您可以复制此模型文件并指向不同的数据库表,也可以添加您创建的其他优化文件,以定义模型中所需的其他图层。 ### 对 PDT 使用优化 如本页中的[与扩展相比的改进](#vs_extends) 部分所述,扩展会创建要扩展的对象的新副本。对于[永久性派生表 (PDT)](https://cloud.google.com/looker/docs/derived-tables?hl=zh-cn#persistent_derived_table) ,您不应使用扩展,因为 PDT 的每个扩展都会在数据库中创建该表的新副本。 不过,您可以向 PDT 的视图添加精炼,因为精炼不会创建要精炼的对象的新副本。 使用元数据查看对象的细化 ------------ 您可以在 Looker IDE 中点击 `explore` 或 `view` 参数,然后使用元数据面板查看对象的任何优化。如需了解详情,请参阅 [LookML 对象的元数据](https://cloud.google.com/looker/docs/lookml-metadata?hl=zh-cn#metadata_for_refinements) 文档页面。 注意事项 ---- ### 已本地化的项目 请注意,在优化对象时,本地化规则也适用于优化结果。如果您要优化对象,然后定义新的标签或说明,则应在项目的语言区域字符串文件中提供本地化定义。如需了解详情,请参阅[将 LookML 模型本地化](https://cloud.google.com/looker/docs/model-localization?hl=zh-cn#understanding_how_localization_rules_apply_to_extended_objects) 文档页面。 发送反馈 如未另行说明,那么本页面中的内容已根据[知识共享署名 4.0 许可](https://creativecommons.org/licenses/by/4.0/) 获得了许可,并且代码示例已根据 [Apache 2.0 许可](https://www.apache.org/licenses/LICENSE-2.0) 获得了许可。有关详情,请参阅 [Google 开发者网站政策](https://developers.google.com/site-policies?hl=zh-cn) 。Java 是 Oracle 和/或其关联公司的注册商标。 最后更新时间 (UTC):2025-04-22。 --- # Penajaman LookML  |  Looker  |  Google Cloud [Langsung ke konten utama](#main-content) [![Google Cloud](https://www.gstatic.com/devrel-devsite/prod/v02f7c7b934487be255c5f28ebb00ed6c2fde7a607ac1d91773e0036b0a06ec31/cloud/images/cloud-logo.svg)](/) / * English * Deutsch * Español – América Latina * Français * Indonesia * Italiano * Português – Brasil * 中文 – 简体 * 日本語 * 한국어 [Konsol](//console.cloud.google.com/?hl=id) Masuk * [Looker](https://cloud.google.com/looker?hl=id) [Hubungi Kami](https://cloud.google.com/contact?hl=id) [Mulai gratis](//console.cloud.google.com/freetrial?hl=id) ![](https://cloud.google.com/_static/images/translated.svg?hl=id) Halaman ini diterjemahkan oleh [Cloud Translation API](//cloud.google.com/translate/?hl=id) . * [Home](https://cloud.google.com/?hl=id) * [Dokumentasi](https://cloud.google.com/docs?hl=id) * [Looker](https://cloud.google.com/looker?hl=id) * [Documentation](https://cloud.google.com/looker/docs?hl=id) * [Panduan](https://cloud.google.com/looker/docs/intro?hl=id) Kirim masukan Penajaman LookML Tetap teratur dengan koleksi Simpan dan kategorikan konten berdasarkan preferensi Anda. =========================================================================================================== Ringkasan --------- Dengan peningkatan LookML, Anda dapat menyesuaikan [tampilan](https://cloud.google.com/looker/docs/reference/param-view-view?hl=id) atau [Jelajahi](https://cloud.google.com/looker/docs/reference/param-explore-explore?hl=id) yang ada tanpa mengedit file LookML yang berisinya. Hal ini sangat cocok untuk: * Project dengan [Looker Blocks](https://cloud.google.com/looker/docs/blocks?hl=id) , yang menggunakan bagian LookML bawaan * Project yang [mengimpor file dari project lain](https://cloud.google.com/looker/docs/importing-projects?hl=id) * Project tempat Anda sering kali perlu [membuat file dari tabel di database](https://cloud.google.com/looker/docs/generating-a-model?hl=id) * Situasi saat Anda ingin membagikan LookML antarmodel atau project sambil melakukan penyesuaian di setiap tempat (konfigurasi hub-and-spoke) Misalnya, jika Anda memiliki file tampilan berikut dalam project: view: flights { sql_table_name: flightstats.accidents ;; dimension: id { label: "id" primary_key: yes type: number sql: ${TABLE}.id ;; } } Anda dapat meningkatkan kualitas tampilan `flights` seperti yang ditunjukkan pada contoh berikut: Gunakan parameter `view` dengan nama tampilan yang sama, tetapi tambahkan tanda plus (`+`) di depan nama untuk menunjukkan bahwa tampilan tersebut merupakan peningkatan kualitas dari tampilan yang ada. Penyempurnaan ini menambahkan dimensi `air_carrier` ke tampilan `flights` yang ada: view: +flights { dimension: air_carrier { type: string sql: ${TABLE}.air_carrier ;; } } Penyempurnaan ini dapat ditempatkan di file LookML apa pun dalam project, seperti file model, file tampilan, atau dalam file LookML khusus. Lihat bagian [Menggunakan penyempurnaan dalam project LookML](#using_refinements_in_your_lookml_project) untuk mengetahui cara kerjanya. Penyempurnaan yang dikombinasikan dengan LookML asli memiliki hasil akhir seolah-olah ini adalah LookML asli untuk tampilan: view: flights { sql_table_name: flightstats.accidents ;; dimension: id { label: "id" primary_key: yes type: number sql: ${TABLE}.id ;; } dimension: air_carrier { type: string sql: ${TABLE}.air_carrier ;; } } Di UI Looker, pengguna akan melihat dimensi **Maskapai Penerbangan**, sama seperti jika Anda telah menambahkan dimensi ke file tampilan asli itu sendiri. Lihat bagian [Contoh](#example) untuk informasi penerapan yang lebih mendetail. ### Peningkatan dibandingkan dengan ekstensi Looker juga mendukung [perluasan](https://cloud.google.com/looker/docs/reusing-code-with-extends?hl=id) objek LookML. Perluasan berguna saat Anda ingin membuat salinan baru dari tampilan atau Jelajahi yang ada sehingga Anda dapat menambahkan objek baru ke dalamnya. Misalnya, Anda dapat membuat tampilan dasar yang menentukan semua kolom, lalu membuat beberapa tampilan baru yang memperluas tampilan dasar. Tampilan baru ini kemudian dapat diubah untuk menyembunyikan kolom tertentu di tampilan dasar, atau untuk mengubah definisi atau label untuk kolom dari tampilan dasar. Penyempurnaan berguna jika Anda ingin mengubah tampilan atau Jelajah yang ada dengan beberapa penyesuaian atau perubahan pada objek tertentu, tetapi tidak ingin membuat salinan tampilan atau Jelajah. Penyempurnaan ideal untuk situasi saat Anda tidak dapat atau tidak ingin mengubah tampilan dasar atau Jelajahi, dan untuk situasi saat membuat tampilan atau Jelajahi baru akan memerlukan perubahan yang ekstensif pada referensi LookML lainnya. Lihat bagian [Contoh](#example) di halaman ini untuk mengetahui contoh kasus penggunaan ini. Untuk sebagian besar kasus penggunaan, peningkatan adalah alternatif yang lebih sederhana dan lebih bersih untuk `extends`. Developer LookML lanjutan mungkin ingin menggunakan parameter [`extends`](https://cloud.google.com/looker/docs/reusing-code-with-extends?hl=id) di dalam penyempurnaan LookML. Lihat bagian [Pemurnian dapat berisi ekstensi](#refinements_can_contain_extends) di halaman ini untuk mengetahui informasi selengkapnya. ### Peningkatan akan menggantikan sebagian besar parameter Perlu diperhatikan bahwa dalam sebagian besar kasus, pengoptimalan akan mengganti setelan asli objek. Pada contoh berikut, tampilan asli memiliki dimensi tersembunyi (`hidden: yes`): view: faa_flights { dimension: carrier { hidden: yes } } Dan dalam file lain, ada peningkatan pada dimensi tersebut dengan `hidden: no`: include: "/views/faa_flights.view.lkml" view: +faa_flights { dimension: carrier { hidden: no } } Penyempurnaan terakhir lebih diutamakan, sehingga `hidden: no` diterapkan dan dimensi akan ditampilkan dalam tampilan akhir. Ada beberapa kasus saat penyempurnaan bersifat _tambahan_, bukan penggantian; lihat bagian [Beberapa parameter bersifat tambahan](#some_parameters_are_additive) di halaman ini untuk mengetahui informasi selengkapnya. ### Beberapa parameter bersifat aditive Dalam banyak kasus, jika penyempurnaan berisi parameter yang sama dengan objek yang sedang ditingkatkan, [penyempurnaan akan mengganti nilai parameter objek yang ditingkatkan](#refinements_override_parameters) . Namun, peningkatan dapat bersifat _aditif_ untuk beberapa parameter, yang berarti bahwa nilai dari objek dasar digunakan bersama dengan nilai dari objek yang ditingkatkan. Parameter berikut bersifat _aditif_: * Untuk dimensi dan ukuran: * [`action`](https://cloud.google.com/looker/docs/reference/param-field-action?hl=id) * [`filters`](https://cloud.google.com/looker/docs/reference/param-field-filters?hl=id) * [`link`](https://cloud.google.com/looker/docs/reference/param-field-link?hl=id) * Untuk parameter: * [`allowed_value`](https://cloud.google.com/looker/docs/reference/param-field-parameter?hl=id#specifying_allowed_values) * Untuk tabel turunan: * [`bind_filters`](https://cloud.google.com/looker/docs/reference/param-view-explore-source?hl=id#bind_filters_example) * [`dev_filters`](https://cloud.google.com/looker/docs/reference/param-view-explore-source?hl=id#dev_filters) * [`filters`](https://cloud.google.com/looker/docs/reference/param-view-explore-source?hl=id#filters) * [`sorts`](https://cloud.google.com/looker/docs/reference/param-view-explore-source?hl=id#sorts) * Untuk penayangan: * [`extends`](https://cloud.google.com/looker/docs/reference/param-view-extends?hl=id) (Lihat bagian [Pemilihan `extends` bersifat tambahan](#additive) di halaman ini untuk mengetahui informasi selengkapnya.) * Untuk Jelajahi: * [`access_filter`](https://cloud.google.com/looker/docs/reference/param-explore-access-filter?hl=id) * [`aggregate_table`](https://cloud.google.com/looker/docs/reference/param-explore-aggregate-table?hl=id) * [`extends`](https://cloud.google.com/looker/docs/reference/param-explore-extends?hl=id) (Lihat bagian [Pemilihan `extends` bersifat tambahan](#additive) di halaman ini untuk mengetahui informasi selengkapnya.) * [`join`](https://cloud.google.com/looker/docs/reference/param-explore-join?hl=id) * [`query`](https://cloud.google.com/looker/docs/reference/param-explore-query?hl=id) Misalnya, berikut adalah tampilan yang memiliki dimensi `name` dengan parameter `link`: 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" } } } Berikut adalah peningkatan pada tampilan `carriers`, dengan dimensi `name` yang memiliki nilai berbeda untuk parameter `link`: include: "/views/carriers.view.lkml" view: +carriers { label: "Refined 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" } } } Dalam tampilan `carriers` yang dioptimalkan, kedua parameter `link` bersifat aditive, sehingga dimensi `name` akan menampilkan kedua link. ![](https://cloud.google.com/static/looker/docs/images/dev-refinements-additive-links-2114.png?hl=id) ### Penyempurnaan diterapkan secara berurutan Objek dapat dioptimalkan beberapa kali dan di beberapa tempat, sehingga developer Looker dapat menggunakan pengoptimalan dengan banyak cara kreatif. Namun, hal ini juga berarti bahwa developer harus sangat memperhatikan urutan penerapan peningkatan: * Dalam project, penyempurnaan diterapkan sesuai urutan file disertakan. Penyempurnaan dari file yang disertakan terakhir akan mengganti penyempurnaan dari file yang disertakan sebelumnya. * Dalam satu file, peningkatan diterapkan baris demi baris ke bawah. Penyempurnaan dengan nomor baris tertinggi diterapkan terakhir dan akan menggantikan penyempurnaan sebelumnya, jika ada konflik. Misalnya, dalam file tampilan berikut, ada dua peningkatan tampilan `faa_flights`. Penyempurnaan pertama menyembunyikan dimensi (`hidden: yes`), dan penyempurnaan kedua menampilkan dimensi (`hidden: no`). Jika ada konflik seperti ini, penyempurnaan yang paling jauh di file akan diprioritaskan: include: "//e_faa_original/views/faa_flights.view.lkml" view: +faa_flights { dimension: carrier { hidden: yes } } view: +faa_flights { dimension: carrier { hidden: no } } Logikanya serupa untuk menyertakan beberapa file dalam project: Penyempurnaan dalam file terakhir yang tercantum dalam include akan diprioritaskan. Misalnya, jika file model menyertakan file berikut: include: "/refinements/distance_analysis.lkml" include: "/refinements/finishing_touches.lkml" Setiap peningkatan kualitas di `distance_analysis.lkml` akan diterapkan terlebih dahulu, lalu setiap peningkatan kualitas di file `finishing_touches.lkml` akan diterapkan. Jika ada konflik, peningkatan kualitas dalam file terakhir, `finishing_touches.lkml`, akan diprioritaskan. ### Menggunakan `final: yes` untuk mencegah peningkatan lebih lanjut Seperti yang dijelaskan sebelumnya, objek yang sama dapat dipertajam beberapa kali di beberapa tempat, dan [pertajaman terakhir](#order) akan [mengganti](#overrides) semua pertajaman sebelumnya. Jika memiliki penyempurnaan yang ingin dianggap sebagai penyempurnaan akhir untuk tampilan atau Jelajahi, Anda dapat menambahkan tanda `final: yes` ke penyempurnaan. IDE Looker akan menampilkan error LookML jika ada penajaman yang akan diterapkan setelah penajaman akhir ini, atau jika developer mencoba menambahkan penajaman baru yang akan diterapkan setelah penajaman akhir ini. Misalnya, penyempurnaan kedua dalam file tampilan ini akan membuat error LookML karena penyempurnaan sebelumnya memiliki tanda `final: yes`: include: "//e_faa_original/views/faa_flights.view.lkml" view: +faa_flights { final: yes dimension: carrier { hidden: yes } } view: +faa_flights { dimension: carrier { hidden: no } } Menambahkan tanda `final: yes` ke penajaman adalah cara yang baik untuk memverifikasi bahwa penajaman diterapkan dalam urutan yang Anda inginkan. ### Penyempurnaan dapat berisi ekstensi Developer LookML lanjutan mungkin ingin menggunakan parameter `extends` di dalam penyempurnaan LookML, yang menambahkan objek yang diperluas ke objek yang sedang ditingkatkan. Untuk meringkas perilaku `extends` dan peningkatan: * Memperluas objek akan membuat salinan baru objek, lalu mem-build-nya. Misalnya, Anda dapat membuat tampilan dasar yang menentukan semua kolom, lalu membuat beberapa tampilan baru yang memperluas tampilan dasar. Setiap tampilan baru ini akan menggabungkan salinan tampilan dasar, dan dari sana developer dapat menambahkan berbagai kolom, filter, atau properti lainnya untuk mengubah tampilan dasar. Idenya adalah Anda memulai dengan objek dasar, lalu menggunakannya dengan cara yang berbeda di beberapa objek lainnya. (Anda dapat melihat halaman dokumentasi [Menggunakan kembali kode dengan ekstensi](https://cloud.google.com/looker/docs/reusing-code-with-extends?hl=id) untuk mengetahui diskusi lengkap tentang cara menggunakan ekstensi.) * Meningkatkan kualitas objek akan menambahkan lapisan modifikasi ke objek, tetapi, tidak seperti memperluas, meningkatkan kualitas tidak membuat beberapa salinan objek. Idenya adalah membuat objek dasar tanpa mengubah LookML aslinya. Sebagai contoh penggunaan standar penajaman, berikut adalah Eksplorasi yang disebut `orders` dan Eksplorasi `+orders` yang mempertajamnya: explore: orders { view_name: orders # other Explore parameters } explore: +orders { label: "Orders Information" # other Explore parameters to build on the original Explore } Selain itu, Anda dapat menambahkan perincian yang menyertakan `extends`. Berdasarkan contoh tersebut, berikut adalah Eksplorasi `orders` yang sama. Namun, selain itu, ada Jelajah dasar yang disebut `users_base`, dan sekarang penyempurnaan `+orders` memiliki parameter `extends` yang menampilkan `users_base`: explore: users_base { view_name: users extension: required # other Explore parameters } explore: orders { view_name: orders # other Explore parameters } explore: +orders { label: "Orders Information" extends: [users_base] # other Explore parameters to build on the original Explore } Yang istimewa di sini adalah penyempurnaan `+orders` memiliki `extends` di dalamnya. Hasilnya adalah tampilan `+orders` kini akan memperluas `users_base` Jelajahi. #### Cara Looker menerapkan `extends` di dalam penyempurnaan Memperluas objek di dalam penyempurnaan adalah konsep LookML lanjutan. Sebelum menggunakan `extends` dalam penyempurnaan, Anda harus memiliki pemahaman mendalam tentang hal berikut: * Cara Looker menerapkan `extends`: Jika elemen LookML ditentukan dalam objek yang diperluas dan objek yang memperluas, versi dalam objek yang memperluas akan digunakan, kecuali jika parameternya [aditif](https://cloud.google.com/looker/docs/reusing-code-with-extends?hl=id#some_parameters_are_additive) . Lihat halaman dokumentasi [Menggunakan kembali kode dengan ekstensi](https://cloud.google.com/looker/docs/reusing-code-with-extends?hl=id#implementation_details_for_extends) untuk mengetahui detailnya. * Cara Looker menerapkan penajaman: Jika elemen LookML ditentukan dalam beberapa penajaman, penajaman terakhir akan menggantikan penajaman sebelumnya. Lihat bagian [Penyesuaian diterapkan secara berurutan](#order) di halaman ini untuk mengetahui detailnya. Terakhir, Anda harus memahami cara Looker menggabungkan prinsip-prinsip ini untuk menerapkan `extends` yang digunakan dalam penyempurnaan. Berikut adalah urutan yang diterapkan Looker, dengan setiap langkah menggantikan langkah sebelumnya jika terjadi konflik: 1. Nilai dari `extends` yang ditentukan dalam objek 2. Nilai dari `extends` yang ditentukan dalam penyempurnaan objek 3. Nilai dari objek 4. Nilai dari peningkatan objek Untuk mengilustrasikan, berikut adalah contoh yang mengikuti nilai parameter `label` melalui setiap langkah penerapan: explore: orders_base { label: "Orders Base" view_name: orders extension: required } explore: users_base { label: "Users Base" view_name: users extension: required } explore: orders { label: "Orders" extends: [orders_base] } explore: +orders { label: "Orders Refined" extends: [users_base] } Berikut cara Looker menerapkan nilai `label` untuk Eksplorasi `orders` dalam contoh ini: 1. **Nilai dari `extends` yang ditentukan dalam objek.** Karena Jelajah `orders` memiliki parameter `extends`, Looker akan dimulai dengan elemen LookML dari objek yang diperluas, yang dalam hal ini adalah Jelajah `orders_base`. Pada tahap ini, nilai `label` adalah "Orders Base". 2. **Nilai dari `extends` yang ditentukan dalam penyempurnaan objek.** Karena `orders` memiliki penyempurnaan, dan penyempurnaan memiliki parameter `extends`, Looker kemudian menerapkan elemen LookML dari ekstensi penyempurnaan, yang dalam hal ini adalah Jelajah `users_base`. Pada tahap ini, nilai `label` adalah "Users Base". 3. **Nilai dari objek.** Setelah semua ekstensi ditangani, Looker akan menerapkan elemen dari objek yang diperluas, yang dalam hal ini adalah `orders` Jelajahi. Jika ada konflik, objek yang diperluas akan menang. Jadi, sekarang nilai `label` adalah "Pesanan". 4. **Nilai dari penyempurnaan objek.** Terakhir, Looker menerapkan elemen dari setiap peningkatan `orders` Jelajah. Jika ada konflik, objek perincian akan menang. Jadi, sekarang nilai `label` adalah "Pesanan Disempurnakan". #### Penajaman `extends` bersifat kumulatif Seperti yang dijelaskan di bagian [Parameter penggantian penyempurnaan](#refinements_override_parameters) di halaman ini, penyempurnaan umumnya mengganti setelan asli objek. Hal ini tidak berlaku untuk parameter `extends`. Jika `extends` digunakan dalam penyempurnaan, nilai dalam parameter `extends` akan ditambahkan ke daftar item yang diperluas dalam objek asli atau dalam penyempurnaan sebelumnya, jika ada. Kemudian, jika ada konflik, prioritas diberikan ke item terakhir dalam rantai ekstensi. Misalnya, berikut adalah Eksplorasi dasar yang disebut `orders_base` dan Eksplorasi `orders` yang memperluas dasar. Selain itu, ada `users_base` Jelajahi dan penyempurnaan `+orders` yang memperluas `users_base`: explore: orders_base { view_name: orders extension: required # other Explore parameters } explore: users_base { view_name: users extension: required # other Explore parameters } explore: orders { extends: [orders_base] # other Explore parameters to build on the base Explore } explore: +orders { extends: [users_base] # other Explore parameters to build on the base Explores } Jelajahi `orders` memperluas `orders_base`, lalu perincian `+orders` menambahkan `users_base` ke daftar `extends`. Hasilnya adalah Eksplorasi `+orders` kini akan memperluas `orders_base` dan `users_base`, seolah-olah ini adalah LookML asli untuk Eksplorasi: explore: orders { extends: [orders_base, users_base] } Kemudian, jika ada konflik, prioritas diberikan ke item terakhir dalam rantai ekstensi. Dalam contoh ini, elemen di `users_base` akan mengganti elemen yang bertentangan di `orders_base`. Konsep memperluas lebih dari satu objek sekaligus dibahas di halaman dokumentasi [Menggunakan kembali kode dengan extends](https://cloud.google.com/looker/docs/reusing-code-with-extends?hl=id#extending_more_than_one_object_at_the_same_time) . Satu hal terakhir yang perlu diperhatikan: dalam contoh ini, urutan parameter `explore` tidak akan berpengaruh. Namun, dalam kasus dengan beberapa perincian objek yang sama, urutan perincian memang penting. Seperti yang dijelaskan di bagian [Penyesuaian diterapkan secara berurutan](#order) di halaman ini, penyesuaian terakhir dalam file akan menggantikan penyesuaian sebelumnya. Menggunakan penajaman dalam project LookML ------------------------------------------ Berikut adalah langkah-langkah umum untuk meningkatkan kualitas tampilan dan Jelajah di project Anda: 1. Identifikasi tampilan atau Jelajahi yang ingin Anda pertajam. 2. Tentukan tempat Anda ingin menyimpan penyempurnaan. Anda dapat menambahkan penyempurnaan dalam file LookML yang ada, atau membuat file LookML terpisah untuk penyempurnaan. (Lihat prosedur untuk [membuat file pengujian data](https://cloud.google.com/looker/docs/other-project-files?hl=id#creating_data_test_files) di halaman dokumentasi **Memahami file project lainnya** untuk mengetahui contoh pembuatan file LookML umum.) 3. Gunakan parameter [`include`](https://cloud.google.com/looker/docs/reference/param-model-include?hl=id) untuk menggabungkan penyempurnaan ke dalam model Anda: * Dalam file tempat Anda menulis penyempurnaan, Anda harus menyertakan file LookML yang sedang Anda sempurnakan. IDE Looker akan memberi Anda peringatan jika Anda mencoba menyaring objek yang tidak disertakan. * Dalam file model, sertakan file tempat penyempurnaan Anda ditentukan. Anda dapat menggabungkan file dan menggunakan include dengan cara yang sangat kreatif; lihat bagian [Menggunakan penyempurnaan untuk menambahkan lapisan ke model Anda](#layers) di halaman ini untuk mengetahui detailnya. Contoh ------ Meningkatkan kualitas objek LookML adalah cara mudah untuk menyesuaikan tampilan dan Jelajah tanpa harus mengedit LookML asli. Hal ini sangat berguna jika tampilan dan Jelajah Anda hanya dapat dibaca di project, seperti dengan [file yang diimpor dari project lain](https://cloud.google.com/looker/docs/importing-projects?hl=id) . Berikut adalah contoh untuk menyaring Jelajah. Berikut adalah LookML untuk Eksplorasi `aircraft`: explore: aircraft { join: aircraft_types { type: left_outer sql_on: ${aircraft.id} = ${aircraft_types.id} ;; relationship: many_to_one } join: aircraft_engine_types { type: left_outer sql_on: ${aircraft.id} = ${aircraft_engine_types.id} ;; relationship: many_to_one } } Eksplorasi ini berisi beberapa tampilan, yang masing-masing memiliki banyak dimensi. Sekarang, project LookML lain yang disebut `e_faa_refined` mengimpor file Eksplorasi `aircraft`. Dalam project `e_faa_refined`, Anda dapat menggunakan penyempurnaan untuk menyederhanakan `aircraft` Jelajah secara drastis. Karena `aircraft` Explore adalah file yang diimpor, Anda tidak dapat mengeditnya secara langsung. Sebagai gantinya, Anda dapat menambahkan perincian ke dalamnya. Berikut adalah contoh file terpisah yang disebut `refinements.lkml` yang berisi LookML ini: include: "//e_faa_original/Explores/aircraft.explore.lkml" explore: +aircraft { label: "Aircraft Simplified" fields: [aircraft.aircraft_serial, aircraft.name, aircraft.count] } File `refinements.lkml` berisi hal berikut: * Parameter `include` untuk memasukkan file `aircraft.explore.lkml` asli dari project yang diimpor (lihat halaman dokumentasi [Mengimpor file dari project lain](https://cloud.google.com/looker/docs/importing-projects?hl=id#referencing_files_from_an_imported_project) untuk mengetahui detail tentang cara merujuk ke file project yang diimpor). * Peningkatan pada Jelajahi `aircraft`: * Tanda `+` di depan nama Jelajah menunjukkan penajaman pada Jelajah yang ada. * Parameter [`label`](https://cloud.google.com/looker/docs/reference/param-explore-label?hl=id) mengubah label Jelajah menjadi "Pesawat Sederhana". * Parameter [`fields`](https://cloud.google.com/looker/docs/reference/param-explore-fields?hl=id) menentukan bahwa hanya tiga kolom yang akan ditampilkan di Jelajahi. Hasil akhirnya akan terlihat seperti tampilan `aircraft` Jelajahi dan `aircraft` asli: explore: aircraft { label: "Aircraft Simplified" } view: aircraft { sql_table_name: flightstats.aircraft ;; dimension: aircraft_serial { type: string sql: ${TABLE}.aircraft_serial ;; } dimension: name { type: string sql: ${TABLE}.name ;; } measure: count { type: count } } Untuk contoh penggunaan penyesuaian untuk menyesuaikan satu tampilan untuk beberapa kasus penggunaan, lihat resep cookbook [Memaksimalkan penggunaan kembali kode dengan DRY LookML: Menyesuaikan satu tampilan dasar untuk beberapa kasus penggunaan](https://cloud.google.com/looker/docs/best-practices/dry-cookbook-5?hl=id) . Kasus penggunaan lainnya untuk peningkatan ------------------------------------------ Seperti yang disebutkan sebelumnya, penyesuaian sangat cocok untuk menyesuaikan objek LookML yang hanya dapat dibaca, seperti [Looker Blocks](https://cloud.google.com/looker/docs/blocks?hl=id) atau [file yang diimpor](https://cloud.google.com/looker/docs/importing-projects?hl=id) . Namun, setelah Anda memahami cara menambahkan peningkatan dan menyertakannya dalam model, Anda dapat melakukan hal-hal yang sangat keren dengan project Anda, seperti yang dijelaskan dalam contoh berikut. ### Menggunakan penyempurnaan untuk menambahkan analisis Anda dapat menggunakan penyesuaian untuk menambahkan analisis ke model tanpa menyentuh file LookML asli. Misalnya, jika ada project tempat tampilan dan Eksplorasi [dibuat dari tabel dalam database Anda](https://cloud.google.com/looker/docs/generating-a-model?hl=id) dan disimpan dalam file LookML bernama `faa_basic.lkml`, Anda dapat membuat file `faa_analysis.lkml` tempat Anda menggunakan penyesuaian untuk menambahkan analisis. Berikut adalah contoh tabel turunan baru yang disebut `distance_stats` yang memiliki analisis jarak. Contoh ini menunjukkan peningkatan `flights` Jelajah yang ada dari file `faa_basic.lkml` yang menggabungkan tabel turunan `distance_stats` ke dalam `flights` Jelajah. Selain itu, di bagian bawah contoh, tampilan `flights` yang ada dioptimalkan untuk menambahkan kolom baru dari analisis: include: "faa_basic.lkml" explore: +flights { join: distance_stats { relationship: one_to_one type: cross } } view: distance_stats { derived_table: { explore_source: flights { bind_all_filters: yes column: distance_avg {field:flights.distance_avg} column: distance_stddev {field:flights.distance_stddev} } } dimension: avg { type:number sql: CAST(${TABLE}.distance_avg as INT64) ;; } dimension: stddev { type:number sql: CAST(${TABLE}.distance_stddev as INT64) ;; } } view: +flights { measure: distance_avg { type: average sql: ${distance} ;; } measure: distance_stddev { type: number sql: STDDEV(${distance}) ;; } dimension: distance_tiered2 { type: tier sql: ${distance} ;; tiers: [500,1300] } } ### Menggunakan penyempurnaan untuk menambahkan lapisan ke model Anda Kasus penggunaan menarik lainnya untuk peningkatan adalah menambahkan lapisan ke project Anda. Anda dapat membuat beberapa file perbaikan, lalu menyertakannya secara strategis untuk menambahkan lapisan. Misalnya, dalam project FAA, ada file `faa_raw.lkml` yang berisi semua tampilan dan Jelajah yang [dibuat dari tabel dalam database Anda](https://cloud.google.com/looker/docs/generating-a-model?hl=id) . File ini memiliki tampilan untuk setiap tabel dalam database, masing-masing dengan dimensi untuk setiap kolom database. Selain file mentah, Anda dapat membuat file `faa_basic.lkml` untuk menambahkan lapisan baru dengan penyempurnaan dasar, seperti menambahkan join ke Jelajah, atau menambahkan ukuran ke tampilan, seperti ini: include: "faa_raw.lkml" explore: +flights { join: carriers { sql_on: ${flights.carrier} = ${carriers.name} ;; } } view: +flights { measure: total_seats { type: sum sql: ${aircraft_models.seats} ;; } } Kemudian, Anda dapat menambahkan file `faa_analysis.layer.lkml` untuk menambahkan lapisan baru dengan analisis (lihat subbagian [Menggunakan penyempurnaan untuk menambahkan analisis](#analysis) untuk contoh file analisis). Dari sana, Anda hanya perlu menyertakan semua file perbaikan ke dalam file model. Anda juga dapat menggunakan file model untuk menambahkan penyempurnaan guna mengarahkan tampilan ke tabel database yang ingin dirujuk: connection: "publicdata_standard_sql" include: "faa_raw.lkml" include: "faa_basic.lkml" include: "faa_analysis.lkml" view: +flights { sql_table_name: lookerdata.faa.flights;; } view: +airports { sql_table_name: lookerdata.faa.airports;; } view: +aircraft { sql_table_name: lookerdata.faa.aircraft;; } view: +aircraft_models{ sql_table_name: lookerdata.faa.aircraft_models;; } view: +carriers { sql_table_name: lookerdata.faa.carriers;; } Anda dapat menduplikasi file model ini dan mengarahkannya ke tabel database yang berbeda, atau Anda dapat menyertakan file peningkatan kualitas yang berbeda yang telah Anda buat untuk menentukan lapisan lain yang Anda inginkan dalam model. ### Menggunakan penyempurnaan untuk PDT Seperti yang dijelaskan di bagian [Pembaruan dibandingkan dengan ekstensi](#vs_extends) di halaman ini, ekstensi membuat salinan baru objek yang diperluas. Untuk [tabel turunan persisten (PDT)](https://cloud.google.com/looker/docs/derived-tables?hl=id#persistent_derived_table) , Anda tidak boleh menggunakan ekstensi, karena setiap ekstensi PDT akan membuat salinan baru tabel di database Anda. Namun, Anda dapat menambahkan perincian ke tampilan PDT, karena perincian tidak membuat salinan baru objek yang sedang diperinci. Menggunakan metadata untuk melihat penyempurnaan objek ------------------------------------------------------ Anda dapat mengklik parameter `explore` atau `view` di Looker IDE dan menggunakan panel metadata untuk melihat peningkatan pada objek. Lihat halaman dokumentasi [Metadata untuk objek LookML](https://cloud.google.com/looker/docs/lookml-metadata?hl=id#metadata_for_refinements) untuk mengetahui informasinya. Hal-hal yang perlu dipertimbangkan ---------------------------------- ### Project dengan pelokalan Saat Anda menyaring objek, perhatikan bahwa aturan pelokalan juga berlaku untuk penyaringan Anda. Jika Anda menyaring objek, lalu menentukan label atau deskripsi baru, Anda harus memberikan definisi pelokalan dalam file string lokalitas project. Lihat halaman dokumentasi [Menlokalkan model LookML](https://cloud.google.com/looker/docs/model-localization?hl=id#understanding_how_localization_rules_apply_to_extended_objects) untuk mengetahui informasi selengkapnya. Kirim masukan Kecuali dinyatakan lain, konten di halaman ini dilisensikan berdasarkan [Lisensi Creative Commons Attribution 4.0](https://creativecommons.org/licenses/by/4.0/) , sedangkan contoh kode dilisensikan berdasarkan [Lisensi Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0) . Untuk mengetahui informasi selengkapnya, lihat [Kebijakan Situs Google Developers](https://developers.google.com/site-policies?hl=id) . Java adalah merek dagang terdaftar dari Oracle dan/atau afiliasinya. Terakhir diperbarui pada 2025-04-22 UTC. --- # Validar seu LookML  |  Looker  |  Google Cloud [Ir para o conteúdo principal](#main-content) [![Google Cloud](https://www.gstatic.com/devrel-devsite/prod/v02f7c7b934487be255c5f28ebb00ed6c2fde7a607ac1d91773e0036b0a06ec31/cloud/images/cloud-logo.svg)](/) / * English * Deutsch * Español – América Latina * Français * Indonesia * Italiano * Português – Brasil * 中文 – 简体 * 日本語 * 한국어 [Console](//console.cloud.google.com/?hl=pt-br) Fazer login * [Looker](https://cloud.google.com/looker?hl=pt-br) [Entre em contato](https://cloud.google.com/contact?hl=pt-br) [Comece gratuitamente](//console.cloud.google.com/freetrial?hl=pt-br) ![](https://cloud.google.com/_static/images/translated.svg?hl=pt-br) Esta página foi traduzida pela [API Cloud Translation](//cloud.google.com/translate/?hl=pt-br) . * [Home](https://cloud.google.com/?hl=pt-br) * [Documentação](https://cloud.google.com/docs?hl=pt-br) * [Looker](https://cloud.google.com/looker?hl=pt-br) * [Documentation](https://cloud.google.com/looker/docs?hl=pt-br) * [Guias](https://cloud.google.com/looker/docs/intro?hl=pt-br) Envie comentários Validar seu LookML Mantenha tudo organizado com as coleções Salve e categorize o conteúdo com base nas suas preferências. ============================================================================================================================ Ao editar o LookML, o ambiente de desenvolvimento integrado do Looker alerta você sobre erros de sintaxe não resolvidos em um único arquivo (consulte a página de documentação [Visão geral do ambiente de desenvolvimento integrado do Looker](https://cloud.google.com/looker/docs/looker-ide?hl=pt-br#ad_hoc_error_checking) ). Para realizar uma validação completa do modelo, use o Validador do LookML. Alguns erros, como uma referência de campo inválida devido a uma mesclagem ausente, exigem uma análise holística do modelo e, portanto, só são exibidos quando o validador do LookML é executado. Valide as mudanças do LookML antes de publicá-las no ambiente de produção. Embora a validação não detecte _todos_ os problemas, como problemas de permissão do banco de dados, ela evita a maioria dos erros. O validador do LookML verifica apenas arquivos que foram atualizados desde a última validação ou que foram afetados por atualizações: * Se uma configuração no nível do modelo for alterada, tudo será validado novamente. * Se uma visualização mudar, apenas as páginas "Explorar" em que ela é usada serão validadas novamente. * Se uma seção "Explorar" mudar, apenas ela será validada novamente. ### Execução da validação Para executar o validador do LookML, selecione o botão **Validar LookML** no canto superior direito do ambiente de desenvolvimento integrado do Looker. Ou selecione o ícone **Saúde do projeto** na parte de cima do ambiente de desenvolvimento integrado para abrir o painel **Saúde do projeto** e clique no ícone **Validar LookML**. ![](https://cloud.google.com/static/looker/docs/images/dev-validate-lookml-2402.png?hl=pt-br) Depois de executar o validador do LookML, você pode conferir uma lista de erros e outros avisos que precisam ser resolvidos. Você pode selecionar qualquer seta para expandir as listas de erros ou avisos. ![](https://cloud.google.com/static/looker/docs/images/lookml-warnings-expanded-list-720.png?hl=pt-br) O botão de validação no painel **Saúde do projeto** vai ficar disponível novamente se você fizer e salvar outra mudança. ### Mensagens de validação O Looker mostra mensagens de validação depois de executar a validação no LookML. #### Nenhum erro do LookML encontrado Quando o validador não encontra problemas, o Looker mostra uma marca de seleção verde com o texto **Nenhum erro do LookML encontrado**. ![](https://cloud.google.com/static/looker/docs/images/no-lookml-errors-720.png?hl=pt-br) #### Erros do LookML Erros do LookML são problemas que podem impedir a execução de consultas. O número entre parênteses é a quantidade de erros encontrados (nove no exemplo abaixo): ![Exemplo de uma mensagem de validação com o texto "Erros do LookML (9)".](https://cloud.google.com/static/looker/docs/images/lookml-errors-message-720.png?hl=pt-br) Na lista expandida de problemas, você vai encontrar o motivo pelo qual a validação não foi aprovada. Muitas vezes, se você clicar no erro, ele vai levar você diretamente para a linha de código com o problema. Um "X" vermelho vai aparecer ao lado da linha. Em alguns casos, passar o cursor sobre ele vai fornecer informações de erro mais detalhadas: ![Exemplo de um erro que aparece ao passar o cursor sobre uma definição de parâmetro de tipo sem valor, com o texto de erro informando que é necessário fornecer um valor para o tipo.](https://cloud.google.com/static/looker/docs/images/lookml-row-error-720.png?hl=pt-br) > **Dica da equipe de chat**: o erro de validação mais comum é "Campo desconhecido ou inacessível". Acesse a página de práticas recomendadas [Erro: campo desconhecido ou inacessível](https://cloud.google.com/looker/docs/best-practices/error-unknown-or-inaccessible-field?hl=pt-br) > para saber as causas e o que fazer. #### Avisos do LookML Os avisos do LookML podem não impedir a execução de uma consulta, mas ainda podem resultar em uma funcionalidade incorreta ou não intencional para os usuários. Assim como nos erros, o número entre parênteses é o número de avisos encontrados (três avisos no exemplo abaixo): ![Exemplo de mensagem de validação com o texto LookML Warnings (3).](https://cloud.google.com/static/looker/docs/images/lookml-warnings-message-720.png?hl=pt-br) Assim como nos erros do LookML, é possível expandir os avisos e pular para o código do problema selecionando o aviso no painel **Saúde do projeto** e passando o cursor sobre o ícone vermelho **X** para conferir mais informações: ![Exemplo de um aviso com texto informando que a Análise precisa corresponder a um nome de visualização ou que ela precisa ter uma propriedade "from" ou "view_name".](https://cloud.google.com/static/looker/docs/images/lookml-row-warning-712.png?hl=pt-br) Como implantar as alterações ---------------------------- Depois de validar que as mudanças vão funcionar corretamente, use a integração do Git do Looker para [confirmar e implantar as mudanças na produção](https://cloud.google.com/looker/docs/version-control-and-deploying-changes?hl=pt-br#getting_your_changes_to_production) . Envie comentários Exceto em caso de indicação contrária, o conteúdo desta página é licenciado de acordo com a [Licença de atribuição 4.0 do Creative Commons](https://creativecommons.org/licenses/by/4.0/) , e as amostras de código são licenciadas de acordo com a [Licença Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0) . Para mais detalhes, consulte as [políticas do site do Google Developers](https://developers.google.com/site-policies?hl=pt-br) . Java é uma marca registrada da Oracle e/ou afiliadas. Última atualização 2025-04-22 UTC. ---