By the end of this tutorial, you'll be able to use Spectacles to check the validity of the SQL defined in the dimensions of your Looker project.
You'll need to give Spectacles a Looker API key so it can run tests. Follow this guide for our recommendations on how to set up an API key for Spectacles.
When you're done, you should have a client ID and client secret that look something like this:
A Suite is a set of instructions that Spectacles follows to run tests on your Looker instance. Among other things, Suites determine:
- How Spectacles runs are triggered (manually, on a schedule, or on pull requests)
- Which types of tests are run (these are called Validators)
- Which models and explores to test
- Notifications for errored and failed runs
For now, we'll create a simple Suite that instructs Spectacles to run SQL validation against our instance every day at 6 AM.
- In the top menu, click Suites.
- Click New Suite.
There are a lot of options on the Suite page, but we'll focus on a small section of it for now.
Name your Suite "SQL Validation"
Configure the Triggers section to schedule the Suite to run at 6:00 UTC each day.
Configure the SQL Validator section with the following options:
- Explores to query:
- Explores to exclude: Leave the default
- Fail fast: Yes
- Query concurrency: Leave the default
- Explores to query:
Uncheck Is Enabled for the Content Validator and the Assert Validator. We'll come back to these validators in a later tutorial.
Click Create Suite.
The Explores to query and Explores to exclude options accept a comma-separated list of model and explore pairs. You can use a wildcard character
* to select all explores within a model or all models and explores (
Here are some examples:
Only Explore A
All explores in Model A
Every explore named Explore A across all models
Explore A and Explore B
You're ready for the final step! To run the SQL Validator, click Run next to your Suite.
Spectacles will run SQL validation against the production branch of your project. In Looker in Admin > Queries, you should be able to see Spectacles running queries as your user.
Congratulations! If Spectacles identified any SQL errors in your explore, try fixing them and re-running the validator.