fix: pass row and result computation for inSet test (#18466)

This commit is contained in:
Teddy 2024-10-31 09:15:18 +01:00 committed by GitHub
parent 7ebc62dca7
commit 9a685d5f19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -45,6 +45,7 @@ class BaseColumnValuesToBeInSetValidator(BaseTestValidator):
Returns:
TestCaseResult:
"""
matched = False
allowed_values = self.get_test_case_param_value(
self.test_case.parameterValues, # type: ignore
"allowedValues",
@ -58,11 +59,12 @@ class BaseColumnValuesToBeInSetValidator(BaseTestValidator):
try:
column: Union[SQALikeColumn, Column] = self._get_column_name()
res = self._run_results(Metrics.COUNT_IN_SET, column, values=allowed_values)
matched = res > 0
if match_enum:
count = self._run_results(
Metrics.ROW_COUNT, column, values=allowed_values
)
res = count - res
matched = count - res == 0
except (ValueError, RuntimeError) as exc:
msg = f"Error computing {self.test_case.fullyQualifiedName}: {exc}" # type: ignore
logger.debug(traceback.format_exc())
@ -81,7 +83,7 @@ class BaseColumnValuesToBeInSetValidator(BaseTestValidator):
return self.get_test_case_result_object(
self.execution_date,
self.get_test_case_status(res == 0 if match_enum else res >= 1),
self.get_test_case_status(matched),
f"Found countInSet={res}.",
[TestResultValue(name=ALLOWED_VALUE_COUNT, value=str(res))],
row_count=row_count,