Skip to main content

Testframework for PySpark DataFrames

Project description

Build Status Version Ruff

pyspark-testframework

Work in progress








The goal of the pyspark-testframework is to provide a simple way to create tests for PySpark DataFrames. The test results are returned in DataFrame format as well.

Example

Input DataFrame:

primary_key email number
1 info@woonstadrotterdam.nl 123
2 infowoonstadrotterdam.nl 01
3 @woonstadrotterdam.nl -45
4 dev@woonstadrotterdam.nl 1.0
5 Null Null
from testframework.tests import RegexTest, IsIntegerString

# test for valid email addresses
email_regex = r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"

mail_tester = RegexTest(
    name="ValidEmail",
    pattern=email_regex
)

test_result_email = mail_tester.test(
    df=df,
    col="email",
    nullable=False
)

# test for integer strings
integer_string_tester = IsIntegerString()

test_result_number = number_tester.test(
    df=df,
    col="number",
    nullable=True
)

test_result_email.show()
test_result_number.show()

Output for ValidEmail:

primary_key email__ValidEmail
1 True
2 False
3 False
4 True
5 False

Output for IsIntegerString:

primary_key number__IsIntegerString
1 True
2 False
3 True
4 True
5 True

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyspark_testframework-1.0.0.tar.gz (13.6 kB view hashes)

Uploaded Source

Built Distribution

pyspark_testframework-1.0.0-py3-none-any.whl (8.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page