This SDF library contains the standard tests available in the default namespace for SDF data tests. As such, tests defined in this workspace do not need to be prefixed with the workspace name, they can be referenced directly. Here's an example:
columns:
- name: a
tests:
- expect: unique()
- expect: not_null()
Note: SDF is still < v1, as such certain scenarios may result in unexpected behavior. Please follow the contributing guidelines and create an issue in this repo if you find any bugs or issues.
For an in-depth guide on how to use SDF tests, please see the Tests section of our official docs
Test Name | Type |
---|---|
not_null() |
Scalar |
valid_scalar(condition) |
Scalar |
valid_aggregate(condition) |
Aggregate |
unique() |
Aggregate |
in_accepted_values([values]) |
Aggregate |
minimum(value) |
Aggregate |
maxiumum(value) |
Aggregate |
exclusive_minimum(value) |
Aggregate |
exclusive_maximum(value) |
Aggregate |
between(lower, upper) |
Aggregate |
max_length(value) |
Aggregate |
min_length(value) |
Aggregate |
like(string) |
Aggregate |
try_cast(type) |
Aggregate |
primary_key(column) |
Aggregate |
unique_columns([c1, c2]) |
Table |
Asserts that no values of a column elements are null.
Example:
columns:
- name: a
tests:
- expect: not_null()
Asserts that all values of a column meet a scalar condition.
Example:
columns:
- name: a
tests:
- expect: valid_scalar("""x == 0 OR x == 1""")
Asserts that all values of a column meet an aggregate condition.
Example:
columns:
- name: a
tests:
- expect: valid_aggregate("""SUM(x) < 100""")
Asserts that all values of a column are unique.
Example:
columns:
- name: a
tests:
- expect: unique()
Asserts that all values of a column are in a list of accepted values.
Example:
columns:
- name: a
tests:
- expect: in_accepted_values([1, 2, 3])
- expect: in_accepted_values(['nyse', 'nasdaq', 'dow'])
Asserts that no values of a column are less than a given value.
Example:
columns:
- name: a
tests:
- expect: minimum(0)
Asserts that no values of a column are greater than a given value.
Example:
columns:
- name: a
tests:
- expect: maximum(100)
Asserts that no values of a column are less than or equal to a given value.
Example:
columns:
- name: a
tests:
- expect: exclusive_minimum(0)
Asserts that no values of a column are greater than or equal to a given value.
Example:
columns:
- name: a
tests:
- expect: exclusive_maximum(100)
Asserts that all values of a column are between two values.
Example:
columns:
- name: a
tests:
- expect: between(0, 100)
Asserts that no string values of a column are greater than a given length.
Example:
columns:
- name: a
tests:
- expect: max_length(100)
Asserts that no string values of a column are less than a given length.
Example:
columns:
- name: a
tests:
- expect: min_length(10)
Asserts that all string values of a column contain a given string.
Example:
columns:
- name: a
tests:
- expect: like('abc')
Asserts that all values of a column can be cast to a given type.
Example:
columns:
- name: a
tests:
- expect: try_cast('int')
Asserts that a column is the Primary Key of a table
Example:
columns:
- name: a
tests:
- expect: primary_key()
Asserts that a combination of columns are unique across a table
Example:
table:
name: a
tests:
- expect: unique_columns(['a', 'b'])