These best practices reflect recommendations shared by a cross-functional team of seasoned Lookers. These insights come from years of experience working with Looker customers from implementation to long-term success. The practices are written to work for most users and situations, but as always use best judgment when implementing.
LookML Dos ✅
- Do: Define the
relationshipparameter for all joins.
This will ensure that metrics aggregate properly within Looker. By default, Looker will utilize many_to_one join relationships for any joins in which a relationship is not defined.
- Do: Define a primary key within each and every view, including derived tables.
All views, whether from the database directly or derived, should contain a primary key. This primary key should be a unique value that would enable Looker to uniquely identify any given record. This primary key can be a single column or a concatenation of columns - it simply needs to be a unique identifier for the table or derived table.
Related: Dealing with Non-Unique Primary Keys
- Do: Name LookML objects using all lowercase letters and underscores for spaces.
The label parameter can be used for additional formatting of a name field.
- Do: Utilize datagroups for aligning PDT generation and Explore caching with underlying ETL processes.
These can also be used in conjunction with schedules for pre-populating cache.
LookML Don’ts ❌
- Don’t: Use the
fromparameter for renaming views within an Explore.
view_labelparameter instead. For more on the difference between
view_label, check out our documentation.The
fromparameter should primarily be utilized in the following situations:
- Polymorphic joins (joining the same table multiple times)
- Self-joins (joining a table to itself)
- Re-scoping an extended view back to its original view name
- Don’t: Use the words “date” or “time” in a dimension group name.
Looker appends each timeframe to the end of the dimension group name. This means that a dimension group named
created_dateresults in fields called
created_date_month, etc. Simply use
createdas the dimension group name, as this results in fields named
- Don’t: Use formatted timestamps within joins.
Instead, use the raw timeframe option for joining on any date or time fields. This will avoid the inclusion of casting and timezone conversion in join predicates.