Repository navigation
Fixes #38561: count no failed rows for a passing == custom SQL test #38607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
a219b31
00fe58f
b7347c8
8158951
45892ee
bd773ac
5f3b6ff
fdb2c07
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -235,8 +235,10 @@ def _calculate_passed_rows_success(self, operator: str, len_rows: int, row_count | |
| passed_rows = (row_count - len_rows) if row_count else 0 | ||
| failed_rows = len_rows | ||
| elif operator == "==": | ||
| passed_rows = len_rows | ||
| failed_rows = (row_count - len_rows) if row_count else 0 | ||
| # == counts how far the result is from the expected count as failed (see | ||
| # _calculate_equal_failure); a pass is exactly on it, so no row failed. | ||
| passed_rows = row_count if row_count else len_rows | ||
| failed_rows = 0 | ||
| else: | ||
| passed_rows = len_rows | ||
| failed_rows = 0 | ||
|
|
@@ -271,16 +273,11 @@ def _calculate_less_than_failure(self, len_rows: int, row_count: int) -> tuple[i | |
| return max(0, passed_rows), max(0, failed_rows) | ||
|
|
||
| def _calculate_equal_failure(self, threshold: int, len_rows: int, row_count: int) -> tuple[int, int]: | ||
| """Calculate rows for == operator failure (expected exact count)""" | ||
| if row_count: | ||
| if len_rows > threshold: | ||
| failed_rows = len_rows - threshold | ||
| passed_rows = row_count - failed_rows | ||
| else: | ||
| failed_rows = row_count - len_rows | ||
| passed_rows = len_rows | ||
| else: | ||
| failed_rows = abs(len_rows - threshold) | ||
| passed_rows = 0 | ||
| """Calculate rows for == operator failure (expected exact count) | ||
|
|
||
| The rows the result is off by, above or below the expected count, are the failed rows. | ||
| """ | ||
| failed_rows = abs(len_rows - threshold) | ||
| passed_rows = (row_count - failed_rows) if row_count else 0 | ||
|
|
||
| return max(0, passed_rows), max(0, failed_rows) | ||
|
Comment on lines
+280
to
283
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Edge Case: == failure can report more failed rows than the table has (>100%)
Cap failed rows at the table row count:
Check the box to apply the fix or reply for a change | Was this helpful? React with 👍 / 👎 |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we count the query matches as failed rows on a passing == check, as we do for <=?
With 10 matches on a 20-row table, == 10 should still succeed and report 10 passed / 10 failed.