Customers Contact TR

Overview of LookML Structures

What is LookML?

LookML (Looker Modeling Language) is Looker’s proprietary language that creates an abstraction layer for SQL databases, enabling users to define dimensions, aggregates, calculations, and relationships. It allows business users to interact with data by generating SQL queries based on the model. This blog provides hands-on experience with LookML fundamentals.


Overview of LookML Structures

The hierarchy of LookML is structured using the following objects:


  • Projects: Libraries of LookML code. Because Looker uses Git for version control, a best practice is for each project to map 1:1 with a Git repository. A project is composed of one or more Models.
  • Models: A set of Explores by business area or need. An Explore is a set of pre-joined views for business-user analysis.Each model contains one or more Explores.
  • Views: Database tables or logical representations of them, including Dimensions (database columns or logical representations) and Measures (aggregate functions on dimensions, such as a COUNT of customers or a SUM of cost).


Projects

The highest-level LookML object is the project. A project is essentially a library of code that typically maps 1:1 to a data source or database connection. You can think of each project as an almost independent mini-instance or microcosm of Looker.


Schemas that cannot be joined together usually reside in different projects because there is no relation to be made across the two datasets. This depends on your database dialect and database user permissions.


A key concept to remember is: if it’s possible in your SQL dialect, it should be possible in Looker. If you can go to your database console and hand-write a SELECT statement that does a thing, you can also code LookML so that Looker does the same thing.



You can share content from one project to another via a feature called Project Import, if necessary, and if it’s enabled for your instance, but this is an advanced approach to setting up your model architecture and not in the scope of this lab.


Models

Models are the next level of the hierarchy and contain the following:


  • The database connection you are using, as defined in the image by line 1.
  • View files accessible to the model, as defined by lines 4, 5, and 6.
  • Definitions of Explores and their join logic.


Models contain data connection information and definitions of Explores. They can be used to restrict user access to certain Explores and organize Explores by business area.


Explores

Explores are one or more views joined together, usually to target a specific business question. They should be organized around business themes to minimize user confusion.


Explores are the “drivers” of analysis on the front end, acting as predefined sets of tables frequently joined for business inquiries and use cases.


Views

Views are where you define dimensions (which are the data attributes) and measures (which are aggregations of dimensions). Think of views as tables that bundle related fields. There are a few different types of views:


  • Standard views: Abstract existing database tables.
  • Virtual tables: Known as derived tables, discussed later in this quest.


Dimensions

The lowest level of a LookML object is fields, which can be Dimensions or Measures. Dimensions are created for any columns that are already in your database tables when the view files are generated from a table by Looker.


You can also create additional dimensions that would serve as logical representations of table columns. These appear in the SELECT and GROUP BY clause of a SQL statement. They are the “attributes” that describe your data.



Measures

Measures are aggregates that do not live explicitly in your database tables. They must be created in LookML. They aggregate dimensions into values like sums or counts.


Note that they do not appear in the GROUP BY statement of the SQL generated by Looker. Instead, they depend on dimensions to determine that grouping.



LookML Hierarchy Recap

To recap, a project is a library of code that models a data source and maps 1:1 to a Git repository.

Projects contain:


  • Model files, which define the Explores that should be packaged together and how those Explores work.
  • View files, which describe database tables or logical representations of them.

Dimensions and Measures within View files.


Author: Umniyah Abbood

Date Published: Dec 16, 2024



Discover more from Kartaca

Subscribe now to keep reading and get access to the full archive.

Continue reading