Skip to content

Assertion

An assertion is a data quality test query that finds rows that violate one or more conditions specified in the query. If the query returns any rows, the assertion fails.

You can create assertions in the following ways. Available config options are defined in AssertionConfig, and are shared across all the following ways of creating assertions.

Using a SQLX file:

-- definitions/name.sqlx
config {
type: "assertion"
}
SELECT * FROM table WHERE a IS NULL

Using built-in assertions in the config block of a table:

See TableConfig.assertions

Using action configs files:

definitions/actions.yaml
actions:
- assertion:
filename: name.sql
-- definitions/name.sql
SELECT * FROM table WHERE a IS NULL

Using the Javascript API:

definitions/file.js
assert("name").query("SELECT * FROM table WHERE a IS NULL")

Note: When using the Javascript API, methods in this class can be accessed by the returned value. This is where query comes from.

  • ActionBuilder‹Assertion›

    Assertion

database(database: string): this

deprecated Deprecated in favor of AssertionConfig.project.

Sets the database in which to create the corresponding view for this assertion. For BigQuery targets this is the Google Cloud project ID; for Postgres/Supabase targets this is the database name configured in workflow_settings.yaml.

Parameters:

NameType
databasestring

Returns: this


dependencies(value: Resolvable | Resolvable[]): this

deprecated Deprecated in favor of AssertionConfig.dependencies.

Sets dependencies of the assertion.

Parameters:

NameType
valueResolvable | Resolvable[]

Returns: this


description(description: string): this

deprecated Deprecated in favor of AssertionConfig.description.

Sets the description of this assertion.

Parameters:

NameType
descriptionstring

Returns: this


disabled(disabled: boolean): this

deprecated Deprecated in favor of AssertionConfig.disabled.

If called with true, this action is not executed. The action can still be depended upon. Useful for temporarily turning off broken actions.

Parameters:

NameTypeDefault
disabledbooleantrue

Returns: this


hermetic(hermetic: boolean): void

deprecated Deprecated in favor of AssertionConfig.hermetic.

If true, this indicates that the action only depends on data from explicitly-declared dependencies. Otherwise if false, it indicates that the action depends on data from a source which has not been declared as a dependency.

Parameters:

NameType
hermeticboolean

Returns: void


query(query: AContextable‹string›): this

Sets the query to be run by the assertion.

Parameters:

NameType
queryAContextable‹string›

Returns: this


schema(schema: string): this

deprecated Deprecated in favor of AssertionConfig.dataset.

Sets the schema in which to create the corresponding view for this assertion. For BigQuery targets this is the dataset name; for Postgres/Supabase targets this is the schema name (e.g. public).

Parameters:

NameType
schemastring

Returns: this


tags(value: string | string[]): this

deprecated Deprecated in favor of AssertionConfig.tags.

Sets a list of user-defined tags applied to this action.

Parameters:

NameType
valuestring | string[]

Returns: this