Created
September 2, 2022 06:32
-
-
Save DaveFlynn/7f26ee7cdecedef332d4b5601dec721f to your computer and use it in GitHub Desktop.
PipeRider Custom Assertion Template
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
class YourAssertionName(BaseAssertionType): | |
def name(self): | |
return "your_assertion_name" | |
def execute(self, context: AssertionContext, table: str, column: str, metrics: dict) -> AssertionResult: | |
column_metrics = metrics.get('tables', {}).get(table, {}).get('columns', {}).get(column) | |
if column_metrics is None: | |
# column could not be found | |
return context.result.fail('column does not exist') | |
# 1. Get the metric for the desired column, e.g. num of nulls in column | |
# 2. Get expectation from assertion file | |
# 3. Implement logic to compare expectated and actual metic value | |
# 4. Return pass or fail based on your testing | |
def validate(self, context: AssertionContext) -> ValidationResult: | |
result = ValidationResult(context) | |
# result.errors.append('explain to users why this broken') | |
return result | |
# 5. register new assertion | |
register_assertion_function(YourAssertionName) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment