-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
258 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import daft | ||
from cuallee import Check | ||
|
||
|
||
def test_positive(check: Check): | ||
check.is_complete("id") | ||
df = daft.from_pydict({"id": [None, None], "id2": [None, None]}) | ||
result = check.validate(df) | ||
assert result.select(daft.col("status").str.match("PASS")).to_pandas().status.all() | ||
|
||
|
||
def test_negative(check: Check): | ||
check.is_empty("id") | ||
df = daft.from_pydict({"id": [10, None], "id2": [300, 500]}) | ||
result = check.validate(df) | ||
assert result.select(daft.col("status").str.match("FAIL")).to_pandas().status.all() | ||
|
||
|
||
def test_coverage(check: Check): | ||
check.is_empty("id", 0.5) | ||
df = daft.from_pydict({"id": [10, None], "id2": [300, 500]}) | ||
result = check.validate(df) | ||
assert result.select(daft.col("status").str.match("PASS")).to_pandas().status.all() | ||
col_pass_rate = daft.col("pass_rate") | ||
assert ( | ||
result.agg(col_pass_rate.max()).select(col_pass_rate == 0.50).to_pandas().pass_rate.all() | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import pandas as pd | ||
from cuallee import Check | ||
import pytest | ||
import duckdb | ||
|
||
|
||
def test_positive(check: Check, db: duckdb.DuckDBPyConnection): | ||
check.is_complete("id") | ||
df = pd.DataFrame({"id": [None, None], "id2": [None, None]}) | ||
check.table_name = "df" | ||
assert check.validate(db).status.str.match("PASS").all() | ||
|
||
|
||
def test_negative(check: Check, db: duckdb.DuckDBPyConnection): | ||
check.is_complete("id") | ||
df = pd.DataFrame({"id": [10, None], "id2": [300, 500]}) | ||
check.table_name = "df" | ||
assert check.validate(db).status.str.match("FAIL").all() | ||
|
||
|
||
def test_coverage(check: Check, db: duckdb.DuckDBPyConnection): | ||
check.is_complete("id", 0.5) | ||
df = pd.DataFrame({"id": [10, None], "id2": [300, 500]}) | ||
check.table_name = "df" | ||
result = check.validate(db) | ||
assert result.status.str.match("PASS").all() | ||
assert result.pass_rate.max() == 0.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import pandas as pd | ||
from cuallee import Check | ||
import pytest | ||
|
||
|
||
def test_positive(check: Check): | ||
check.is_empty("id") | ||
df = pd.DataFrame({"id": [None, None], "id2": [None, None]}) | ||
assert check.validate(df).status.str.match("PASS").all() | ||
|
||
|
||
def test_negative(check: Check): | ||
check.is_empty("id") | ||
df = pd.DataFrame({"id": [10, None], "id2": [300, 500]}) | ||
assert check.validate(df).status.str.match("FAIL").all() | ||
|
||
|
||
def test_coverage(check: Check): | ||
check.is_empty("id2", 0.5) | ||
df = pd.DataFrame({"id": [10, None], "id2": [300, 500]}) | ||
assert result.status.str.match("PASS").all() | ||
assert result.pass_rate.max() == 0.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import polars as pl | ||
from cuallee import Check | ||
import pytest | ||
|
||
|
||
def test_positive(check: Check): | ||
check.is_empty("id") | ||
df = pl.DataFrame({"id": [None, None], "id2": [None, None]}) | ||
result = check.validate(df).select(pl.col("status")) == "PASS" | ||
assert all(result.to_series().to_list()) | ||
|
||
|
||
def test_negative(check: Check): | ||
check.is_empty("id") | ||
df = pl.DataFrame({"id": [10, None], "id2": [300, 500]}) | ||
result = check.validate(df).select(pl.col("status")) == "FAIL" | ||
assert all(result.to_series().to_list()) | ||
|
||
|
||
def test_coverage(check: Check): | ||
check.is_empty("id2", 0.5) | ||
df = pl.DataFrame({"id": [10, None], "id2": [300, 500]}) | ||
|
||
result = check.validate(df).select(pl.col("status")) == "PASS" | ||
assert all(result.to_series().to_list()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import pytest | ||
|
||
from cuallee import Check, CheckLevel | ||
|
||
|
||
def test_positive(spark): | ||
df = spark.createDataFrame([[None], [None], [None], [None], [None]], ["id"]) | ||
check = Check(CheckLevel.WARNING, "pytest") | ||
check.is_empty("id") | ||
rs = check.validate(df) | ||
assert rs.first().status == "PASS" | ||
assert rs.first().violations == 0 | ||
assert rs.first().pass_threshold == 1.0 | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"data, violation, pass_rate", | ||
[ | ||
[[[0], [1], [None], [4], [5]], 4, 1 / 5], | ||
[[[0], [1], [None], [4], [None]], 3, 2 / 5], | ||
], | ||
ids=("one_null_value", "two_null_value"), | ||
) | ||
def test_negative(spark, data, violation, pass_rate): | ||
df = spark.createDataFrame(data, ["id"]) | ||
check = Check(CheckLevel.WARNING, "pytest") | ||
check.is_empty("id") | ||
rs = check.validate(df) | ||
assert rs.first().status == "FAIL" | ||
assert rs.first().violations == violation | ||
assert rs.first().pass_threshold == 1.0 | ||
assert rs.first().pass_rate >= pass_rate | ||
|
||
|
||
def test_parameters(): | ||
return "😅 No parameters to be tested!" | ||
|
||
|
||
def test_coverage(spark): | ||
df = spark.createDataFrame([[0], [1], [None], [4], [5]], ["id"]) | ||
check = Check(CheckLevel.WARNING, "pytest") | ||
check.is_empty("id", 0.1) | ||
rs = check.validate(df) | ||
assert rs.first().status == "PASS" | ||
assert rs.first().pass_threshold == 0.1 | ||
assert rs.first().pass_rate >= 1 / 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import pytest | ||
|
||
from cuallee import Check, CheckLevel | ||
|
||
|
||
def test_positive(snowpark): | ||
df = snowpark.createDataFrame([[None], [None]], ["ID"]) | ||
check = Check(CheckLevel.WARNING, "pytest") | ||
check.is_empty("ID") | ||
rs = check.validate(df) | ||
assert rs.first().STATUS == "PASS" | ||
assert rs.first().VIOLATIONS == 0 | ||
assert rs.first().PASS_THRESHOLD == 1.0 | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"data, violation, pass_rate", | ||
[ | ||
[[[0], [1], [None], [4], [5]], 4, 1 / 5], | ||
[[[0], [1], [None], [4], [None]], 3, 2 / 5], | ||
], | ||
ids=("one_null_value", "two_null_value"), | ||
) | ||
def test_negative(snowpark, data, violation, pass_rate): | ||
df = snowpark.createDataFrame(data, ["ID"]) | ||
check = Check(CheckLevel.WARNING, "pytest") | ||
check.is_empty("ID") | ||
rs = check.validate(df) | ||
assert rs.first().STATUS == "FAIL" | ||
assert rs.first().VIOLATIONS == violation | ||
assert rs.first().PASS_THRESHOLD == 1.0 | ||
assert rs.first().PASS_RATE == pass_rate | ||
|
||
|
||
def test_parameters(): | ||
return "😅 No parameters to be tested!" | ||
|
||
|
||
def test_coverage(snowpark): | ||
df = snowpark.createDataFrame([[0], [1], [None], [4], [5]], ["ID"]) | ||
check = Check(CheckLevel.WARNING, "pytest") | ||
check.is_empty("ID", 0.1) | ||
rs = check.validate(df) | ||
assert rs.first().STATUS == "PASS" | ||
assert rs.first().PASS_THRESHOLD == 0.1 | ||
assert rs.first().PASS_RATE == 1 / 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters