Knowledge Drop

Error: Unknown view. View does not exist in model. Check for typos or missing include statements.

  • 5 April 2021
  • 1 reply
  • 276 views

Userlevel 5
Badge
  • Looker Staff
  • 159 replies

Last tested: March 2021

Problem

You receive a LookML error that complains about an unknown view. The error takes the form:

Unknown view “my_view”. View “my_view” does not exist in model “my_model”. Check for typos or missing include statements in “my_model”.

Solution 1

The most simple reason for this error is, as the error states, someone simply forgot to include that view into the model. Or perhaps the view name is misspelled!

If the include statement specifies the view, but the warning triangle states "This include does not match any files," confirm that the proper folder path has been written for the include statement.

Includes with Folders.png

Solution 2

A second, much more complex reason is when the view is renamed with from. Generally, it is best to use view_name when you don't need to rename the view, such as when using extends, and reserve from when you need to change how the view is referenced, such as joining a view to an explore more than once.

Example when using from with extends

  • When using from , you reference fields using explore_name.field_name .

  • When using view_name , you reference fields using view_name.field_name .

The from parameter causes a big problem when extending, because now the explore name has changed!

# CODE WHICH ERRORSexplore: my_explore {from: my_viewjoin: other_view { sql_on: ${my_explore.field1} = ${other_view.field1};;}explore: new_explore {extends: [my_explore]}

Inside new_explore , the join on line 5 is brought through but the reference to my_explore fails because the explore name is now new_explore .

To fix this, use view_name instead!

# CODE WHICH DOES NOT ERROR (we changed lines 4 and 5 only)explore: my_explore {view_name: my_viewjoin: other_view { sql_on: ${my_view.field1} = ${other_view.field1};;}explore: new_explore {extends: [my_explore]}

Now, the reference on line 5 is only based on the view, not the explore. So when it's brought into new_explore via extends, the reference is still valid. The key is that there are now no references to the old explore name (my_explore )!

 

This content is subject to limited support.                


1 reply

It is for this reason we often see a common design pattern in development to not allow multiple ways to do the same thing! I would recommend in the future that there be only one way to key fields, aka, explicitly force people to specify a view name, or change the way extends work.

Reply