mihaibudiu commented on code in PR #5306:
URL: https://github.com/apache/calcite/pull/5306#discussion_r4189718478
##########
core/src/test/java/org/apache/calcite/test/SqlFunctionsTest.java:
##########
@@ -117,6 +117,55 @@ static <E> List<E> list() {
return ImmutableList.of();
}
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-7837">[CALCITE-7837]
+ * ARRAY_MIN, ARRAY_MAX and SORT_ARRAY throw ClassCastException for ROW
elements</a>. */
+ @Test void testArrayComparisonWithSpecialFloatingPointValues() {
+ final List<Double> values =
+ list(Double.NaN, null, Double.NEGATIVE_INFINITY, 1D,
Double.POSITIVE_INFINITY);
+ assertThat(SqlFunctions.arrayMax(values), is(Double.NaN));
+ assertThat(SqlFunctions.arrayMin(values), is(Double.NEGATIVE_INFINITY));
+ assertThat(SqlFunctions.sortArray(values, true),
+ is(list(null, Double.NEGATIVE_INFINITY, 1D, Double.POSITIVE_INFINITY,
Double.NaN)));
+ assertThat(SqlFunctions.sortArray(values, false),
+ is(list(Double.NaN, Double.POSITIVE_INFINITY, 1D,
Double.NEGATIVE_INFINITY, null)));
+ }
+
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-7837">[CALCITE-7837]
+ * ARRAY_MIN, ARRAY_MAX and SORT_ARRAY throw ClassCastException for ROW
elements</a>. */
+ @Test void testArrayRowComparisonWithSpecialFloatingPointValues() {
+ for (double special : new double[] {
+ Double.NaN, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY}) {
+ final boolean specialFirst = Double.compare(special, 1D) < 0;
Review Comment:
These observations are unrelated to the issue being solved, but they are
related to the code here.
That's why it's good to solve problems one at a time.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]