Repository navigation
Fixes #35274: count no failed rows for an open between bound and compare boolean sets as booleans - #35276
Conversation
…oolean sets as booleans
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
TeddyCr
left a comment
There was a problem hiding this comment.
Reviewed at 39f86c3.
Both diagnoses in #35274 are right, and the between-bounds fix is correct. The new _no_bounds cases run against real SQLite and fail without the change. Two things block merge:
- CI is red because of this change: basedpyright on
sqa_validator_mixin.py:197(inline). - Regression on datalake: pandas infers string
"True"/"False"columns as BOOLEAN, so the new set parsing turns string sets into bools that no longer match (inline onget_set_param_value, with a repro).
Also: this targets 2.0, but main has both bugs (literal_eval in the set validators, the empty-filter between count). Is a main PR planned?
| return self.get_test_case_param_value( | ||
| self.test_case.parameterValues, # type: ignore | ||
| param_name, | ||
| partial(utils.parse_set_values, column_type=self.get_column().type), |
There was a problem hiding this comment.
Regression on the pandas/datalake path. For pandas, get_column().type is not the declared column type. It is inferred by GenericDataFrameColumnParser.fetch_col_types, which runs ast.literal_eval on the values of object-dtype columns. As a result, a column of the strings "True"/"False" is reported as DataType.BOOLEAN, and parse_set_values turns the user's string set into Python bools that no longer match the data:
df = pd.DataFrame({"s": ["True", "False", "True"]}) # dtype object, real strings
GenericDataFrameColumnParser.fetch_col_types(df, "s") # -> DataType.BOOLEAN
df[~df.s.isin([True, False])].shape # (3, 2) all rows fail (this PR)
df[~df.s.isin(["True", "False"])].shape # (0, 2) before this PRSo on a datalake source, columnValuesToBeInSet(["True","False"]) with matchEnum goes from Success to failing every row, and NotInSet goes from catching the values to catching none. Suggest only converting when the data really is boolean: on pandas, check the dataframe dtype is bool, or keep the conversion on the SQLAlchemy side where the type comes from the engine. A pandas case for this belongs in test_validations_datalake.py.
Also, PandasValidatorMixin.get_column() does next(dfs()), which loads the first chunk. This helper now calls it again in _get_test_parameters, in the dimensional path and in filter(), which means extra object-store reads per test on datalake. Passing in the column the caller already resolved avoids that.
There was a problem hiding this comment.
Fixed by keeping the conversion on the SQLAlchemy side, as you suggested. get_set_param_value now asks a new get_set_values_type() hook, which resolves through the mixins the same way get_column does. SQAValidatorMixin returns the engine's column type. PandasValidatorMixin returns None, so pandas sets stay as written and the helper no longer loads a chunk.
| filters = [ | ||
| (expression, op, bound) for op, bound in (("lt", min_bound), ("gt", max_bound)) if not is_unbounded(bound) | ||
| ] | ||
| return ( |
There was a problem hiding this comment.
This is what turns python / Unit Tests & Static Checks (3.10) red: basedpyright reports Type "Unknown | Literal[0] | None" is not assignable to return type "int" at 197:16, because _compute_row_count_between returns Optional. Either annotate -> Optional[int] (callers already put it in failed_rows) or coalesce with or 0. A new violation fails CI even though the baseline exists.
The logic itself looks right: one-sided windows keep their single filter, and a datetime bound stays bounded through is_unbounded. That matches the old not isinstance(..., (int, float)) guard in columnValuesToBeBetween.
There was a problem hiding this comment.
Fixed: annotated -> Optional[int], which matches what callers already put in failed_rows.
| return [_as_boolean(value) for value in values] if is_boolean(column_type) else values | ||
|
|
||
|
|
||
| def _as_boolean(value): |
There was a problem hiding this comment.
Only true/false (case-insensitive) are mapped. "1"/"0", "t"/"f" and "yes"/"no" stay strings, so Databricks will still abort on a set like ["1","0"]. That's fine if it's deliberate, but the parse_set_values docstring should say so. Separately, if allowedValues ever parses to a bare string ('"true"'), the comprehension iterates over its characters. Guarding with isinstance(values, (list, tuple, set)) would make that a clear error instead.
There was a problem hiding this comment.
Deliberate: only true/false (any case) are mapped, since that's what the UI and generated tests write. The parse_set_values docstring now says so, and that "1"/"0", "t"/"f" and "yes"/"no" stay as written.
| self.ALLOWED_VALUES, | ||
| literal_eval, | ||
| ) | ||
| allowed_values = self.get_set_param_value(self.ALLOWED_VALUES) |
There was a problem hiding this comment.
Nit: _get_test_parameters() runs before the try in _run_validation, and it now calls get_column(). A missing or renamed column used to hit the local except (ValueError, RuntimeError) and return Aborted with allowedValueCount=None. Now it escapes to the catch-all in TestSuiteInterface.run_test_case. The result is still Aborted, but it comes with a logger.exception stack trace and an empty result-values list. Moving the _get_test_parameters() call inside the try keeps the old behavior. The same applies to columnValuesToBeNotInSet.py:56.
There was a problem hiding this comment.
Agreed. Moved _get_test_parameters() inside the try in both columnValuesToBeInSet and columnValuesToBeNotInSet, so a missing column is Aborted through the local handler again.
| Check if _type is a boolean, as a sqlalchemy type or an OpenMetadata DataType | ||
| """ | ||
| return ( | ||
| _type.value == DataType.BOOLEAN.value if isinstance(_type, DataType) else issubclass(_type.__class__, Boolean) |
There was a problem hiding this comment.
Nit: _type == DataType.BOOLEAN and isinstance(_type, Boolean) are equivalent and match how the neighboring helpers read.
| None, | ||
| ), | ||
| ( | ||
| "test_case_column_value_in_set_boolean_strings", |
There was a problem hiding this comment.
Good regression test: on SQLite, 'true' IN (...) against the 0/1 boolean column counts 0, so this fails without the fix. Coverage is only on the SQLAlchemy InSet path, though. There's nothing for NotInSet and nothing on pandas, which is where the regression above sits. Could you add columnValuesToBeNotInSet with ["true"] here, and the string-booleans pandas case in test_validations_datalake.py?
There was a problem hiding this comment.
Added test_case_column_values_not_in_set_boolean_strings: NotInSet with ["true"] on the boolean column, giving Failed with 40 forbidden out of 80 rows. The pandas string-boolean case is in test_validations_datalake.py
…eanly on a missing column
… test definitions
Code Review ✅ Approved🟡 Medium risk · Changing open-bound row counts and boolean set parsing could incorrectly mark data-quality tests as passing or failing for affected columns. Fixes two data quality runners on VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|



Describe your changes:
Fixes #35274
I fixed two data quality runners on
2.0that reported wrong results:columnValuesToBeBetween/columnValueLengthsToBeBetweenwindow that is unset (or -inf/+inf) now excludes no row. Before, both sides open produced an empty filter list, the failed-row count ran without aWHERE, and the test passed while reporting every row as failed."true"/"false"compare as booleans. Before,literal_evalkept them as strings and Databricks aborted the test on the type mismatch.Type of change:
High-level design:
validations/utils.py:is_unbounded(bound)(None, or a float that is infinite; a datetime window is always a real bound) andparse_set_values(raw, column_type)(literal_eval, then"true"/"false"to booleans when the column is boolean).profiler/orm/registry.py:is_boolean(_type)for both a SQLAlchemy type and an OpenMetadataDataType, next tois_date_time.mixins/sqa_validator_mixin.py:_count_rows_outside(runner, column, expression, min_bound, max_bound)builds thelt/gtfilters from the bounded sides only and returns 0 when neither side is bounded. Both SQLAlchemy between validators use it, and theirfilter()usesis_unbounded, so the failed-row sample and the count agree.base_test_handler.py:get_set_param_value(param_name)reads a set typed by the validated column; the six set validators (base, SQLAlchemy, pandas,InSetandNotInSet) call it instead ofliteral_eval.BetweenBoundsCheckeralready skips infinite bounds; the pandas between validators already count 0 rows outside an open window; the failed-row sample is only fetched for a Failed result, which an all-open window cannot produce.Tests:
Use cases covered
columnValuesToBeBetweentest with no bounds: Success, 80 passed / 0 failed on the sample DB (was 0 / 80).columnValueLengthsToBeBetweentest with no bounds: Success, 80 / 0 (was 0 / 80). The one-sidedno_mincase is unchanged.columnValuesToBeInSeton a BOOLEAN column with["true", "false"]: same result as[True, False](Success, 70 / 10).Unit tests
tests/unit/observability/data_quality/conftest.py,tests/unit/observability/data_quality/test_validations_databases.py(..._no_boundsx2,test_case_column_value_in_set_boolean_strings),tests/unit/observability/data_quality/validations/test_utils.py(test_is_unbounded,parse_set_valuesandis_booleancases). Each new test failed before the change.tests/unit/observability/data_quality+tests/unit/data_quality: 404 passed.tests/unit/observability: 942 passed, 2 skipped; 1 failure intest_sqa_profiler_interface.py::test_get_all_metricsonly under-n auto(shared SQLite table race, 8/8 pass serially) and 3 collection errors for thedatabricksmodule not installed locally.tests/unit/sampler: 95 passed.Backend integration tests
Ingestion integration tests
Playwright (UI) tests
Manual testing performed
columnValuesToBeBetweenwith dynamic assertion and no learned bound (open window): before 0 passed / 100 failed, after 100 passed / 0 failed.matchEnum): each result matched the data.UI screen recording / screenshots:
Not applicable.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.Summary by Gitar
tableCustomSQLQuerystrategy andcolumnValuesToBeInSetmatchEnum descriptions in the JSON definitionsThis will update automatically on new commits.