mirror of https://github.com/apache/druid.git
Add option to compare results with relative error tolerance (#15429)
Adds a result comparision mode of EQUALS_RELATIVE_1000_ULPS ; which accepts floating point differences up-to 1000 units of least precision
This commit is contained in:
parent
58a724c7e4
commit
ca544e552c
|
@ -1128,6 +1128,36 @@ public class BaseCalciteQueryTest extends CalciteTestBase
|
|||
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);
|
||||
|
|
|
@ -371,13 +371,13 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1484,7 +1484,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest
|
|||
windowQueryTest();
|
||||
}
|
||||
|
||||
@NotYetSupported(Modes.RESULT_MISMATCH)
|
||||
@DrillTest("frameclause/defaultFrame/RBUPACR_int11")
|
||||
@Test
|
||||
public void test_frameclause_defaultFrame_RBUPACR_int11()
|
||||
|
@ -1772,7 +1771,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest
|
|||
windowQueryTest();
|
||||
}
|
||||
|
||||
@NotYetSupported(Modes.RESULT_MISMATCH)
|
||||
@DrillTest("frameclause/RBUPACR/RBUPACR_int11")
|
||||
@Test
|
||||
public void test_frameclause_RBUPACR_RBUPACR_int11()
|
||||
|
@ -6667,7 +6665,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest
|
|||
windowQueryTest();
|
||||
}
|
||||
|
||||
@NotYetSupported(Modes.RESULT_MISMATCH)
|
||||
@DrillTest("frameclause/defaultFrame/RBUPACR_bgint_4")
|
||||
@Test
|
||||
public void test_frameclause_defaultFrame_RBUPACR_bgint_4()
|
||||
|
@ -6829,7 +6826,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest
|
|||
windowQueryTest();
|
||||
}
|
||||
|
||||
@NotYetSupported(Modes.RESULT_MISMATCH)
|
||||
@DrillTest("frameclause/multipl_wnwds/avg_mulwds")
|
||||
@Test
|
||||
public void test_frameclause_multipl_wnwds_avg_mulwds()
|
||||
|
@ -7048,7 +7044,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest
|
|||
windowQueryTest();
|
||||
}
|
||||
|
||||
@NotYetSupported(Modes.RESULT_MISMATCH)
|
||||
@DrillTest("frameclause/RBUPACR/RBUPACR_bgint_4")
|
||||
@Test
|
||||
public void test_frameclause_RBUPACR_RBUPACR_bgint_4()
|
||||
|
@ -7163,7 +7158,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest
|
|||
windowQueryTest();
|
||||
}
|
||||
|
||||
@NotYetSupported(Modes.RESULT_MISMATCH)
|
||||
@DrillTest("frameclause/RBUPAUF/RBUPAUF_bgint_4")
|
||||
@Test
|
||||
public void test_frameclause_RBUPAUF_RBUPAUF_bgint_4()
|
||||
|
@ -7262,7 +7256,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest
|
|||
windowQueryTest();
|
||||
}
|
||||
|
||||
@NotYetSupported(Modes.RESULT_MISMATCH)
|
||||
@DrillTest("frameclause/subQueries/frmInSubQry_57")
|
||||
@Test
|
||||
public void test_frameclause_subQueries_frmInSubQry_57()
|
||||
|
@ -7270,7 +7263,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest
|
|||
windowQueryTest();
|
||||
}
|
||||
|
||||
@NotYetSupported(Modes.RESULT_MISMATCH)
|
||||
@DrillTest("frameclause/subQueries/frmInSubQry_58")
|
||||
@Test
|
||||
public void test_frameclause_subQueries_frmInSubQry_58()
|
||||
|
@ -7855,7 +7847,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest
|
|||
windowQueryTest();
|
||||
}
|
||||
|
||||
@NotYetSupported(Modes.T_ALLTYPES_ISSUES)
|
||||
@DrillTest("nestedAggs/frmclause12")
|
||||
@Test
|
||||
public void test_nestedAggs_frmclause12()
|
||||
|
@ -7863,7 +7854,6 @@ public class DrillWindowQueryTest extends BaseCalciteQueryTest
|
|||
windowQueryTest();
|
||||
}
|
||||
|
||||
@NotYetSupported(Modes.T_ALLTYPES_ISSUES)
|
||||
@DrillTest("nestedAggs/frmclause16")
|
||||
@Test
|
||||
public void test_nestedAggs_frmclause16()
|
||||
|
|
|
@ -88,7 +88,7 @@ public @interface NotYetSupported
|
|||
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");
|
||||
|
||||
|
|
Loading…
Reference in New Issue