This is an automated email from the ASF dual-hosted git repository.
abhishek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git
The following commit(s) were added to refs/heads/master by this push:
new ca544e552cf Add option to compare results with relative error
tolerance (#15429)
ca544e552cf is described below
commit ca544e552cfa6861c4488e18da3f3c72418447e2
Author: Zoltan Haindrich <[email protected]>
AuthorDate: Tue Nov 28 08:33:16 2023 +0100
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
---
.../druid/sql/calcite/BaseCalciteQueryTest.java | 30 ++++++++++++++++++++++
.../druid/sql/calcite/DrillWindowQueryTest.java | 14 ++--------
.../apache/druid/sql/calcite/NotYetSupported.java | 2 +-
3 files changed, 33 insertions(+), 13 deletions(-)
diff --git
a/sql/src/test/java/org/apache/druid/sql/calcite/BaseCalciteQueryTest.java
b/sql/src/test/java/org/apache/druid/sql/calcite/BaseCalciteQueryTest.java
index bdaecd165cf..1b38a57382d 100644
--- a/sql/src/test/java/org/apache/druid/sql/calcite/BaseCalciteQueryTest.java
+++ b/sql/src/test/java/org/apache/druid/sql/calcite/BaseCalciteQueryTest.java
@@ -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);
diff --git
a/sql/src/test/java/org/apache/druid/sql/calcite/DrillWindowQueryTest.java
b/sql/src/test/java/org/apache/druid/sql/calcite/DrillWindowQueryTest.java
index f1ef60951ab..0a82564e644 100644
--- a/sql/src/test/java/org/apache/druid/sql/calcite/DrillWindowQueryTest.java
+++ b/sql/src/test/java/org/apache/druid/sql/calcite/DrillWindowQueryTest.java
@@ -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()
diff --git
a/sql/src/test/java/org/apache/druid/sql/calcite/NotYetSupported.java
b/sql/src/test/java/org/apache/druid/sql/calcite/NotYetSupported.java
index 7f4e6a06993..c660e0cae21 100644
--- a/sql/src/test/java/org/apache/druid/sql/calcite/NotYetSupported.java
+++ b/sql/src/test/java/org/apache/druid/sql/calcite/NotYetSupported.java
@@ -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");
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]