Skip to content
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

Add option to compare results with relative error tolerance #15429

Merged
merged 4 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,36 @@ void validate(int row, int column, ValueType type, Object expectedCell, Object r
EQUALS.validate(row, column, type, expectedCell, resultCell);
}
}
},
/**
* Comparision which accepts 1000 units of least precision.
*/
EQUALS_RELATIVE_1000_ULPS {
static final int ASSERTION_ERROR_ULPS = 1000;

@Override
void validate(int row, int column, ValueType type, Object expectedCell, Object resultCell)
{
if (expectedCell instanceof Float) {
float eps = ASSERTION_ERROR_ULPS * Math.ulp((Float) expectedCell);
assertEquals(
mismatchMessage(row, column),
(Float) expectedCell,
(Float) resultCell,
eps
);
} else if (expectedCell instanceof Double) {
double eps = ASSERTION_ERROR_ULPS * Math.ulp((Double) expectedCell);
assertEquals(
mismatchMessage(row, column),
(Double) expectedCell,
(Double) resultCell,
eps
);
} else {
EQUALS.validate(row, column, type, expectedCell, resultCell);
}
}
};

abstract void validate(int row, int column, ValueType type, Object expectedCell, Object resultCell);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,13 +371,13 @@ public void verify(String sql, QueryResults queryResults)
results.sort(new ArrayRowCmp());
expectedResults.sort(new ArrayRowCmp());
}
assertResultsEquals(sql, expectedResults, results);
assertResultsValid(ResultMatchMode.EQUALS_RELATIVE_1000_ULPS, expectedResults, queryResults);
}
catch (AssertionError e) {
log.info("query: %s", sql);
log.info(resultsToString("Expected", expectedResults));
log.info(resultsToString("Actual", results));
throw e;
throw new AssertionError(StringUtils.format("%s while processing: %s", e.getMessage(), sql), e);
}
}

Expand Down Expand Up @@ -1484,7 +1484,6 @@ public void test_frameclause_defaultFrame_RBUPACR_dt_3()
windowQueryTest();
}

@NotYetSupported(Modes.RESULT_MISMATCH)
@DrillTest("frameclause/defaultFrame/RBUPACR_int11")
@Test
public void test_frameclause_defaultFrame_RBUPACR_int11()
Expand Down Expand Up @@ -1772,7 +1771,6 @@ public void test_frameclause_RBUPACR_RBUPACR_dt_3()
windowQueryTest();
}

@NotYetSupported(Modes.RESULT_MISMATCH)
@DrillTest("frameclause/RBUPACR/RBUPACR_int11")
@Test
public void test_frameclause_RBUPACR_RBUPACR_int11()
Expand Down Expand Up @@ -6667,7 +6665,6 @@ public void test_frameclause_defaultFrame_RBUPACR_bgint_3()
windowQueryTest();
}

@NotYetSupported(Modes.RESULT_MISMATCH)
@DrillTest("frameclause/defaultFrame/RBUPACR_bgint_4")
@Test
public void test_frameclause_defaultFrame_RBUPACR_bgint_4()
Expand Down Expand Up @@ -6829,7 +6826,6 @@ public void test_frameclause_defaultFrame_RBUPACR_vchr_5()
windowQueryTest();
}

@NotYetSupported(Modes.RESULT_MISMATCH)
@DrillTest("frameclause/multipl_wnwds/avg_mulwds")
@Test
public void test_frameclause_multipl_wnwds_avg_mulwds()
Expand Down Expand Up @@ -7048,7 +7044,6 @@ public void test_frameclause_RBUPACR_RBUPACR_bgint_3()
windowQueryTest();
}

@NotYetSupported(Modes.RESULT_MISMATCH)
@DrillTest("frameclause/RBUPACR/RBUPACR_bgint_4")
@Test
public void test_frameclause_RBUPACR_RBUPACR_bgint_4()
Expand Down Expand Up @@ -7163,7 +7158,6 @@ public void test_frameclause_RBUPACR_RBUPACR_vchr_5()
windowQueryTest();
}

@NotYetSupported(Modes.RESULT_MISMATCH)
@DrillTest("frameclause/RBUPAUF/RBUPAUF_bgint_4")
@Test
public void test_frameclause_RBUPAUF_RBUPAUF_bgint_4()
Expand Down Expand Up @@ -7262,15 +7256,13 @@ public void test_frameclause_subQueries_frmInSubQry_55()
windowQueryTest();
}

@NotYetSupported(Modes.RESULT_MISMATCH)
@DrillTest("frameclause/subQueries/frmInSubQry_57")
@Test
public void test_frameclause_subQueries_frmInSubQry_57()
{
windowQueryTest();
}

@NotYetSupported(Modes.RESULT_MISMATCH)
@DrillTest("frameclause/subQueries/frmInSubQry_58")
@Test
public void test_frameclause_subQueries_frmInSubQry_58()
Expand Down Expand Up @@ -7855,15 +7847,13 @@ public void test_nestedAggs_frmclause03()
windowQueryTest();
}

@NotYetSupported(Modes.T_ALLTYPES_ISSUES)
@DrillTest("nestedAggs/frmclause12")
@Test
public void test_nestedAggs_frmclause12()
{
windowQueryTest();
}

@NotYetSupported(Modes.T_ALLTYPES_ISSUES)
@DrillTest("nestedAggs/frmclause16")
@Test
public void test_nestedAggs_frmclause16()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ enum Modes
INCORRECT_SYNTAX(DruidException.class, "Incorrect syntax near the keyword"),
// at least c7 is represented oddly in the parquet file
T_ALLTYPES_ISSUES(AssertionError.class, "(t_alltype|allTypsUniq|fewRowsAllData).parquet.*Verifier.verify"),
RESULT_MISMATCH(AssertionError.class, "assertResultsEquals"),
RESULT_MISMATCH(AssertionError.class, "(assertResultsEquals|AssertionError: column content mismatch)"),
UNSUPPORTED_NULL_ORDERING(DruidException.class, "(A|DE)SCENDING ordering with NULLS (LAST|FIRST)"),
CANNOT_TRANSLATE(DruidException.class, "Cannot translate reference");

Expand Down