Fixes #7094 by fixing minior bugs in table tests (#7095)

This commit is contained in:
Teddy 2022-08-31 21:35:33 +02:00 committed by GitHub
parent ed58c27f76
commit ef41382cb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 10 deletions

View File

@ -6,14 +6,14 @@
"testPlatforms": ["OpenMetadata", "GreatExpectations"],
"parameterDefinition": [
{
"name": "minColValue",
"displayName": "minColValue",
"name": "minValue",
"displayName": "minValue",
"description": "Expected number of columns should be greater than or equal to {minValue}. If minValue is not included, maxValue is treated as upperBound and there will be no minimum number of column",
"dataType": "INT"
},
{
"name": "maxColValue",
"displayName": "maxColValue",
"name": "maxValue",
"displayName": "maxValue",
"description": "Expected number of columns should be less than or equal to {maxValue}. If maxValue is not included, minValue is treated as lowerBound and there will be no maximum number of column",
"dataType": "INT"
}

View File

@ -103,7 +103,7 @@ validation_enum_registry.add("TableColumnCountToBeBetween")(
)
validation_enum_registry.add("TableColumnToMatchSet")(table_column_to_match_set)
validation_enum_registry.add("TableColumnNameToExist")(table_column_name_to_exist)
validation_enum_registry.add("TableCustomSQLQuery")(table_custom_sql_query)
validation_enum_registry.add("tableCustomSQLQuery")(table_custom_sql_query)
# # Column Tests
validation_enum_registry.add("columnValuesToBeBetween")(column_values_to_be_between)

View File

@ -72,12 +72,23 @@ def table_custom_sql_query(
testResultValue=[TestResultValue(name="resultRowCount", value=None)],
)
status = TestCaseStatus.Success if not rows else TestCaseStatus.Failed
result = f"Found {len(rows)} row(s). Test query is expected to return 0 row."
if not rows:
status = TestCaseStatus.Success
result_value = 0
elif len(rows) == 1:
status = TestCaseStatus.Success if rows[0].count == 0 else TestCaseStatus.Failed
result_value = rows[0].count
else:
status = TestCaseStatus.Failed
result_value = len(rows)
result = f"Found {result_value} row(s). Test query is expected to return 0 row."
return TestCaseResult(
timestamp=execution_date,
testCaseStatus=status,
result=result,
testResultValue=[TestResultValue(name="resultRowCount", value=str(len(rows)))],
testResultValue=[
TestResultValue(name="resultRowCount", value=str(result_value))
],
)

View File

@ -614,7 +614,7 @@ class testSuiteValidation(unittest.TestCase):
],
)
res = validation_enum_registry.registry["TableCustomSQLQuery"](
res = validation_enum_registry.registry["tableCustomSQLQuery"](
test_case=test_case,
execution_date=EXECUTION_DATE.timestamp(),
runner=self.runner,
@ -636,7 +636,7 @@ class testSuiteValidation(unittest.TestCase):
],
)
res = validation_enum_registry.registry["TableCustomSQLQuery"](
res = validation_enum_registry.registry["tableCustomSQLQuery"](
test_case=test_case,
execution_date=EXECUTION_DATE.timestamp(),
runner=self.runner,