[BUGFIX] Render id/pk-only unexpected indices instead of raising (fixes #11933)#11935
Open
anxkhn wants to merge 1 commit into
Open
[BUGFIX] Render id/pk-only unexpected indices instead of raising (fixes #11933)#11935anxkhn wants to merge 1 commit into
anxkhn wants to merge 1 commit into
Conversation
👷 Deploy request for niobium-lead-7998 pending review.Visit the deploys page to approve it
|
Author
|
@cla-bot check |
fivetran#11933) When a COMPLETE result provides unexpected_index_column_names and the unexpected index records carry only the id/pk columns (Spark/SQL paths, and when exclude_unexpected_values=True), _convert_unexpected_indices_to_df computed an empty domain_column_name_list and called unexpected_index_df.groupby([]), which raises ValueError: No group keys passed! and aborted Data Docs rendering. Aggregate all records into a single row in that case so the count/index table renders. The domain-column path is unchanged.
c658c0e to
378edd4
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #11933.
Description
When a COMPLETE validation result provides
unexpected_index_column_namesand theunexpected-index records carry only the id/pk columns, Data Docs rendering
aborts with
ValueError: No group keys passed!.render/util.py::_convert_unexpected_indices_to_dfderives the domain column(s)to group on as
set(record.keys()) - set(unexpected_index_column_names). When therecords hold only the pk columns, that set difference is empty, so the code calls
unexpected_index_df.groupby([]), which raises. This happens on the Spark/SQLpaths and whenever
exclude_unexpected_values=True(the metric builders emitrecords with only the pk columns). The exception propagates out of the unexpected
table renderer and breaks the result page.
This change handles the empty-domain case: instead of
groupby([]), it aggregatesevery record into a single row (
groupby(by=lambda _: "")) and then flows throughthe unchanged count / index-truncation /
head()steps, so the count+index tablerenders. The normal domain-column path is byte-for-byte unchanged.
Tests
tests/render/test_util.pygains two tests that fail-first withValueError: No group keys passed!on the pre-fix code and pass after the change:test_convert_unexpected_indices_to_df_only_id_pk_columnstest_build_count_and_index_table_only_id_pk_columnsThe module already sets
pytestmark = pytest.mark.unit.tests/render/runs169 passed, 2 xfailed (pre-existing).
Open question
The no-domain row has no distinct unexpected value, so the value cell renders
"EMPTY" (the caller's existing
unexpected_value == ""branch). That reusesexisting prior art (
test_build_count_and_index_table_with_empty_string) and isthe minimal, consistent choice, but if you'd prefer a different label here (blank,
or something like "(all rows)") I'm happy to adjust.
invoke lint(usesruff format+ruff check)