Skip to content

sdf-labs/tests

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SDF Workspace Compiles

Official SDF Tests Library

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

SDF Standard Library Tests

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

Not Null

Asserts that no values of a column elements are null.

Example:

columns:
  - name: a
    tests:
      - expect: not_null()

Valid Scalar

Asserts that all values of a column meet a scalar condition.

Example:

columns:
  - name: a
    tests:
      - expect: valid_scalar("""x == 0 OR x == 1""")

Valid Aggregate

Asserts that all values of a column meet an aggregate condition.

Example:

columns:
  - name: a
    tests:
      - expect: valid_aggregate("""SUM(x) < 100""")

Unique

Asserts that all values of a column are unique.

Example:

columns:
  - name: a
    tests:
      - expect: unique()

In Accepted Values

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'])

Minimum

Asserts that no values of a column are less than a given value.

Example:

columns:
  - name: a
    tests:
      - expect: minimum(0)

Maximum

Asserts that no values of a column are greater than a given value.

Example:

columns:
  - name: a
    tests:
      - expect: maximum(100)

Exclusive Minimum

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)

Exclusive Maximum

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)

Between

Asserts that all values of a column are between two values.

Example:

columns:
  - name: a
    tests:
      - expect: between(0, 100)

Max Length

Asserts that no string values of a column are greater than a given length.

Example:

columns:
  - name: a
    tests:
      - expect: max_length(100)

Min Length

Asserts that no string values of a column are less than a given length.

Example:

columns:
  - name: a
    tests:
      - expect: min_length(10)

Like

Asserts that all string values of a column contain a given string.

Example:

columns:
  - name: a
    tests:
      - expect: like('abc')

Try Cast

Asserts that all values of a column can be cast to a given type.

Example:

columns:
  - name: a
    tests:
      - expect: try_cast('int')

Primary Key

Asserts that a column is the Primary Key of a table

Example:

columns:
  - name: a
    tests:
      - expect: primary_key()

Unique Columns

Asserts that a combination of columns are unique across a table

Example:

table:
  name: a
  tests:
    - expect: unique_columns(['a', 'b'])

About

Standard testing library for SDF data tests

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages