User Guide Getting Started Help Center Documentation Community Training
Looker
Looker Blocks

Looker Blocks are building blocks — pre-built pieces of LookML that you can leverage to accelerate your analytics. Reuse the work others have already done rather than starting from scratch, then customize the blocks to your exact specifications. From optimized SQL patterns to fully built-out data models, Looker Blocks can be used as a starting point for quick and flexible data modeling in Looker.

Available Blocks

There are many Looker Blocks to choose from. To see what blocks are currently available, check out the Blocks Directory or select a category below:

Click a block that interests you to see its specific usage instructions.

Standardization and Customization

The ease of using the different blocks will vary, depending on the degree to which your database schema is standardized. Most Looker Blocks require some customization to fit your data schema, with the exception of Data Blocks, which are the simplest to implement but are not customizable.

If you’re new to Looker, your Looker analyst can help you get the most from these models.

Adding Blocks to Your LookML

Using Data Blocks

Data Blocks are special types of Looker Blocks that provide the dataset as well as the data model. Looker Data Blocks include public data sources, such as:

The Weather and Exchange Rate blocks are updated nightly. The other datasets are fairly static and will require minimal updates.

To see the full list of currently available blocks, see the Data Block category of the Blocks Directory.

Accessing Datasets on Google BigQuery

If you have an existing Google BigQuery account, you can access our BigQuery-hosted datasets. Skip ahead to the Adding Data Blocks to Projects section of this page.

If you do not already have a Google BigQuery account, you can set up a free trial and then access Looker’s public datasets on BigQuery.

Accessing Datasets on Snowflake

You can access a Looker-hosted Snowflake data warehouse and use data sharing to get access to Looker’s public datasets.

First, reach out to your Looker analyst with the following information:

Once Looker’s Ops team provides the Snowflake account with access to the Data Blocks, run the following commands to get access to Looker’s public datasets:

‐‐ Data Consumer Side (* Need to be ACCOUNT ADMIN *) ‐‐ For customers in us-west region create database looker_datablocks from share looker.looker_share_datablocks; ‐‐ For customers in us-east region create database looker_datablocks from share gt97609.looker_share_datablocks; grant imported privileges on database looker_datablocks to role sysadmin; use role sysadmin; grant imported privileges on database looker_datablocks to ; show databases; use looker_datablocks; show tables;

Accessing Datasets on Other Databases

Are you on Amazon Redshift? MySQL? PostgreSQL? Oracle?

We’ve made the transformed data for each of these datasets publicly available in both GCS and S3 so that you can directly import them into the database of your choice.

We’ve also made the Data Definition Language (DDL) available for each of the datasets in the GitHub Repo. The DDL statements might need to be modified for the datatypes in your selected database, but should provide an idea of the column types for each table.

Download data directly from one of these locations:

Accessing the LookML Model

Fork one of our GitHub repos into a new GitHub repo (either hosted by Looker or by your company) that you can then extend within your instance:

Adding Data Blocks to Projects

To add a Data Block to your project:

  1. Add a new project to your Looker instance.

  2. Fork or copy the GitHub repos mentioned above to access prebuilt LookML. Be sure to create a new GitHub repo.

  3. Remove other database dialects files from the repo. Our blocks will typically contain files for Google BigQuery, Amazon Redshift, and Snowflake. For example, if you are setting up Data Blocks on Google BigQuery, you will only need the Google BigQuery view files, Google BigQuery Explore file, and Google BigQuery model file.

  4. Replace the connection name in your model file with your database connection where the data for Data Blocks lives, or in the case of Google BigQuery and Snowflake, your existing database connection from which you will be extending:

    All join logic exists in an .explore file in each of the repositories. This is the file you will be including in the following steps, after you have set up your project manifest.

  5. Enable Project Import to build on top of our prebuilt Data Block. This is currently a Looker Labs feature that has to be turned on.

  6. In your main Looker project where you will be extending Data Blocks, create a project manifest file:

  7. Add the following LookML to the project manifest file to reference Data Blocks in your main Looker project:

    project_name: "<your_project_name>" local_dependency: { project: "<project_name_of_datablock>" }

You now have access to the modeled tables. You can extend from the available Explore files or use granular joins at the view level.

Setup Considerations and Options

Google BigQuery: Be sure to use the correct set of modeled files. If you are on Google BigQuery you may want to reference all files with _bq_ in the file name. You may have to adapt our Google BigQuery model dialects to your own database dialect.

Extensions: All of our projects have been set up to allow for extensions from Explore files, since model extension could cause issues with multiple connections.

Joining Derived Tables: You may want to take a look at our documentation for native derived tables. You can let Looker write SQL for you at different levels of aggregation on our publicly available datasets and join them into your model.

Merging Result Sets: You can also choose to merge result sets from our datasets with your data by combining query result sets. View this short video to learn more about merging data.

Example Setup of the Demographic Dataset

  1. Get access to data by either downloading raw data from our S3 or GCS buckets or by connecting to a Looker database.

  2. Import the Demographic Data Block model from LookML as a separate project in your Looker instance:

  3. Enable the Project Import Labs feature and update the project manifest file.

  4. Pull in or extend the view file, or make use of native derived tables to get data at the level of aggregation necessary for Explores.

    In our example, since the demographic data is at a different level of aggregation than our e-commerce dataset (block group vs. zip code) we use native derived tables to aggregate stats up to the zip code level. This eliminates messy many-to-many joins:

    include: "/american_community_survey/bq.explore" view: zipcode_income_facts { derived_table: { persist_for: "10000 hours" explore_source: fast_facts { column: ZCTA5 { field: tract_zcta_map.ZCTA5 } column: income_household { field: bg_facts.avg_income_house } column: total_population { field: bg_facts.total_population } } } dimension: ZCTA5 {} dimension: income_household { hidden: yes }

  5. Join view files into the model:

    include: "acs*.view" explore: order_items { join: users { sql_on: ${users.id} = ${order_items.user_id} ;; type: left_outer relationship: many_to_one } join: zipcode_income_facts { sql_on: ${users.zip} = ${zipcode_income_facts.ZCTA5} ;; type: left_outer relationship: many_to_one } }

  6. Explore your data:

  7. Visualize your data:

Using Viz Blocks

Looker includes a variety of native visualization types. However, if, you have charting needs that are not covered by Looker’s native visualization types, you can also add your own custom visualization types.

Viz Blocks are pre-built JavaScript visualization types that are hosted by Looker. You can add the Viz Blocks to your Looker instance, and they will act like any of Looker’s native visualization types: they appear on the visualization menu bar, and they include core functionality such as drilling, downloading, embedding, and scheduling.

To learn more about a Viz Block, select the visualization type in the Viz Block category of the Blocks Directory, then click See the Code and navigate to the Viz Block’s READ.ME file. The READ.ME file shows an example of the visualization and gives more information about the Viz Block. For some visualizations the READ.ME file also provides a URL and instructions for adding the Viz Block.

To add the visualization type to your instance, see the instructions in the READ.ME file (if any) and the information on our Visualizations documentation page.

Top