Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added brief docs and examples for all supported tests #4

Merged
merged 3 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/compile-workspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
uses: sdf-labs/sdf-action@v0
id: sdf
with:
sdf_version: 0.3.1
command: 'sdf compile'

# Use the output from the `sdf` step
Expand Down
216 changes: 216 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,219 @@ columns:

For an in-depth guide on how to use SDF tests, please see the Tests section of [our official docs](https://docs.sdf.com/guide/data-quality/tests)


## SDF Standard Library Tests

| Test Name | Type |
| ------------------------------ | --------- |
| [`not_null()`](#not-null) | Scalar |
| [`valid_scalar(condition)`](#valid-scalar) | Scalar |
| [`valid_aggregate(condition)`](#valid-aggregate) | Aggregate |
| [`unique()`](#unique) | Aggregate |
| [`in_accepted_values([values])`](#in-accepted-values) | Aggregate |
| [`minimum(value)`](#minimum) | Aggregate |
| [`maxiumum(value)`](#maximum) | Aggregate |
| [`exclusive_minimum(value)`](#exclusive-minimum) | Aggregate |
| [`exclusive_maximum(value)`](#exclusive-maximum) | Aggregate |
| [`between(lower, upper)`](#between) | Aggregate |
| [`max_length(value)`](#max-length) | Aggregate |
| [`min_length(value)`](#min-length) | Aggregate |
| [`like(string)`](#like) | Aggregate |
| [`try_cast(type)`](#try-cast) | Aggregate |
| [`primary_key(column)`](#primary-key) | Aggregate |
| [`unique_columns([c1, c2])`](#unique-columns)| Table |


#### Not Null

Asserts that no values of a column elements are null.

**Example:**
```yaml
columns:
- name: a
tests:
- expect: not_null()
```

#### Valid Scalar

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

**Example:**
```yaml
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:**
```yaml
columns:
- name: a
tests:
- expect: valid_aggregate("""SUM(x) < 100""")
```

#### Unique

Asserts that all values of a column are unique.

**Example:**
```yaml
columns:
- name: a
tests:
- expect: unique()
```

#### In Accepted Values

Asserts that all values of a column are in a list of accepted values.

**Example:**
```yaml
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:**
```yaml
columns:
- name: a
tests:
- expect: minimum(0)
```

#### Maximum

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

**Example:**
```yaml
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:**
```yaml
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:**
```yaml
columns:
- name: a
tests:
- expect: exclusive_maximum(100)
```

#### Between

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

**Example:**
```yaml
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:**
```yaml
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:**
```yaml
columns:
- name: a
tests:
- expect: min_length(10)
```

#### Like

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

**Example:**
```yaml
columns:
- name: a
tests:
- expect: like('abc')
```

#### Try Cast

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

**Example:**
```yaml
columns:
- name: a
tests:
- expect: try_cast('int')
```

#### Primary Key

Asserts that a column is the Primary Key of a table

**Example:**
```yaml
columns:
- name: a
tests:
- expect: primary_key()
```

#### Unique Columns

Asserts that a combination of columns are unique across a table

**Example:**
```yaml
table:
name: a
tests:
- expect: unique_columns(['a', 'b'])
```