Dataform Javascript API Reference › Globals › "core/actions/assertion" › 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 NULLUsing built-in assertions in the config block of a table:
Using action configs files:
# definitions/actions.yaml
actions:
- assertion:
filename: name.sql-- definitions/name.sql
SELECT * FROM table WHERE a IS NULLUsing 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 (Google Cloud project ID) in which to create the corresponding view for this assertion.
Parameters:
| Name | Type |
|---|---|
database |
string |
Returns: this
▸ dependencies(value: Resolvable | Resolvable[]): this
deprecated Deprecated in favor of
AssertionConfig.dependencies.
Sets dependencies of the assertion.
Parameters:
| Name | Type |
|---|---|
value |
Resolvable | Resolvable[] |
Returns: this
▸ description(description: string): this
deprecated Deprecated in favor of
AssertionConfig.description.
Sets the description of this assertion.
Parameters:
| Name | Type |
|---|---|
description |
string |
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:
| Name | Type | Default |
|---|---|---|
disabled |
boolean | true |
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:
| Name | Type |
|---|---|
hermetic |
boolean |
Returns: void
▸ query(query: AContextable‹string›): this
Sets the query to be run by the assertion.
Parameters:
| Name | Type |
|---|---|
query |
AContextable‹string› |
Returns: this
▸ schema(schema: string): this
deprecated Deprecated in favor of
AssertionConfig.dataset.
Sets the schema (BigQuery dataset) in which to create the corresponding view for this assertion.
Parameters:
| Name | Type |
|---|---|
schema |
string |
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:
| Name | Type |
|---|---|
value |
string | string[] |
Returns: this