View the original community article here
Last tested: Jun 28, 2021
This is technically possible, but we recommend against it, mainly for readability and organizational purposes. There are very few instances where it would be recommended/preferable to do this.
You can technically define any object you want inside any file. The LookML parser starts at a model file, and then prepends the model file with any files in include:
statements, making one "giant file". So, in this way, it doesn't really matter which file view or explore objects are defined in.
For best practices, it is much cleaner to keep all explores inside model files, to keep view objects inside view files, and to only define one view per view file.
You may encounter atypical types of modeling either in discourse examples, like this one, where we give an example like this:
connection: "bigquery_publicdata_standard_sql"
explore: persons {
join: persons_cities_lived {
....
join: persons_phone_number {
.....
}
}
view: persons {}
view: persons_cities_lived {
....
}
view: persons_phone_number {
...
}
Typically, your project would be separated by Model and View files. The example above would be modeled in the following way:
Model
connection: "bigquery_publicdata_standard_sql"
explore: persons {
join: persons_cities_lived {
....
join: persons_phone_number {
.....
}
3 separate View Files
view: persons {}
view: persons_cities_lived {}
view: persons_phone_number {
...
}
This content is subject to limited support.