[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-30。"],[],[],null,["# Troubleshooting an example of an advanced extends use case\n\n\u003e *This page covers an advanced topic and assumes a solid knowledge of LookML on the part of the reader.*\n\n\n[Extends](/looker/docs/reusing-code-with-extends) is a valuable LookML feature that allows you to maintain DRY (don't repeat yourself) LookML code. In Looker, [Explores](/looker/docs/reference/param-explore-extends), [views](/looker/docs/reference/param-view-extends), and [LookML dashboards](/looker/docs/reusing-code-with-extends#extending_a_lookml_dashboard) can all be extended with the `extends` parameter within a model file, such as in the following example: \n\n```\nexplore: orders {\n view_name: orders\n join: users {\n type: left_outer\n sql_on: %{orders.user_id} = ${users.id} ;;\n relationship: many_to_one\n }\n}\n\nexplore: transactions {\n extends: [orders]\n}\n```\n\n\nIn this example, the `extends` parameter is used within the definition of the `transactions` Explore to extend the `orders` Explore.\n\n\nThis page refers to the object that is being extended as the *base* object, and the object that is doing the extending is referred to as the *extending* object.\n\n\nExtending a LookML object is a fairly straightforward process, as detailed on the [Reusing code with extends](/looker/docs/reusing-code-with-extends#details_of_extend_functionality) documentation page. However, there are some advanced use cases that can cause LookML reference errors and unwanted object duplication. This page provides an example of how extending an Explore based on a view that extends another view can result in LookML reference errors, as well as tips that can help eliminate such issues.\n\nUse case: Extending an Explore based on an extending view\n---------------------------------------------------------\n\n\nSuppose you want to extend the `events` Explore, and you want the view that the extending Explore is based on to use fields from a view that extends the base `events` view. In this example, the `events_extended` Explore extends the `extends` Explore, as shown in the following example LookML: \n\n```\nexplore: events {\n view_name: events\n join: users {\n type: left_outer\n sql_on: ${events.user_id} = ${users.id} ;;\n relationship: many_to_one\n }\n}\n\nexplore: events_extended {\n extends: [events]\n join: orders {\n sql_on: ${events_extended.test_id} = ${orders.id} ;;\n relationship: many_to_one\n }\n```\n\n\nIn this example, the `users` view is joined to the base `events` Explore, while the `orders` view is joined to the extending Explore, `events_extended`. However, the join defined in the base `events` Explore references `events.user_id`, which is a field from the base `events` view. Meanwhile, the join defined in the extending `events_extended` Explore references the field `events_extended.test_id`, where `events_extended` is the name of an extending view based on the `events` view. The `test_id` field that is referenced in the join in the `events_extended` Explore definition is defined in the extending `events_extended` view as follows: \n\n```\ninclude: \"events.view.lkml\"\nview: events_extended {\n extends: [events]\n\n dimension: test_id {}\n```\n\n\nBecause the join defined in the `events_extended` Explore references the name of the extending view, `events_extended`, the [LookML Validator](/looker/docs/lookml-validation#validating_your_lookml) displays an [`inaccessible view`](/looker/docs/error-catalog#inaccessible_view_(?)._(?)_is_not_accessible_in_explore_(?)._check_for_missing_joins_in_explore_(?).) error.\n\n\nTo address this, you can add the [`from`](/looker/docs/reference/param-explore-from) parameter to the LookML for the extending Explore and set its value to the name of the extending view, `events_extended`. The `from` parameter aliases the original table name in the generated SQL, as `FROM schema.name AS alias`.\n\u003e *This is the only recommended use case for applying the `from` parameter at the Explore level.*\n\n\nTo pull from the extending view (`events_extended`) without breaking the join references from the base Explore (`events`), you can add a `from` parameter that maps to the extending view: \n\n```\nexplore: events_extended {\n extends: [events]\n from: events_extended\n join: orders {\n relationship: many_to_one\n sql_on: ${events.test_id} = ${orders.id} ;;\n }\n}\n```\n\n\nIn this example, applying the LookML `from: events_extended` to the LookML for the extending Explore lets you continue referencing the base view (`events`) in the extending Explore, while redirecting those references to pull from the extending version of that view (`events_extended`).\n\n\nWith the use of the `from` parameter, you can continue to reference the base view name `events` in the join prefixes, but these references will pull from the extending view `events_extended`, which contains all the fields in `events`, plus the new `test_id` field.\n\n\u003cbr /\u003e"]]