SQL Query

Overview

The SQL Query monitor is used when Sifflet's templates are not enough. It allows the specification of custom SQL code and Sifflet will then analyze the results of the query.

SQL

The SQL parameter requires a SQL that is able to run on the database that your asset lives on. It will execute with the default database and schema of the asset you selected but you are able to join to other tables as you would in SQL.

Success and Failure

The SQL Query Monitor will fail whenever rows are returned by the query.

If you want the SQL Query monitor to error whenever there are any rows with a value over 100 you simply need to write a request that fetches those rows.

SELECT * FROM orders where value > 100

AI Features

AI-Driven SQL generation

Sifflet's AI Assistant can generate SQL for you!

Sifflet leverages the power of all the documented context of your catalog to better understand your prompts. If columns are named in complex ways, having descriptions in the catalog will help the AI agent generate better SQL


Fix SQL with AI for SQL Query Monitors

Sometimes it's hard to write SQL correctly, if the Test Run fails Sifflet will now display the option to use AI to attempt to generate correct SQL.

An incorrect column name was used

An incorrect column name was used

Limitations

In the event when the Custom SQL Query is a multi-step SQL (also known as SQL Script), It is not possible for Sifflet to wrap the query in order to count the number of rows returned. In this case Sifflet falls back to a degraded mode and can only check the number of returned rows to a capped maximum of 1000 rows. If more rows are returned, the monitor will simply shows 1000 in this case.