Github user fhueske commented on a diff in the pull request:
https://github.com/apache/flink/pull/5961#discussion_r186484649
--- Diff:
flink-java/src/test/java/org/apache/flink/api/java/operator/MaxByOperatorTest.java
---
@@ -230,4 +235,43 @@ public String toString() {
}
}
+ /**
+ * Validates that no ClassCastException happens
+ * should not fail e.g. like in FLINK-8255.
+ */
+ @Test
+ public void testMaxMinByRowTypeInfoKeyFieldsDataset() {
+
+ final ExecutionEnvironment env = ExecutionEnvironment
+ .getExecutionEnvironment();
+ TypeInformation[] types = new TypeInformation[] {Types.INT,
Types.INT};
+
+ String[] fieldNames = new String[]{"id", "value"};
+ RowTypeInfo rowTypeInfo = new RowTypeInfo(types, fieldNames);
+ DataSet tupleDs = env
+ .fromCollection(Collections.singleton(new Row(2)),
rowTypeInfo);
+
+ tupleDs.maxBy(0);
+ tupleDs.minBy(0);
+ }
+
+ /**
+ * Validates that no ClassCastException happens
+ * should not fail e.g. like in FLINK-8255.
+ */
+ @Test
+ public void testMaxMinByRowTypeInfoKeyFieldsForUnsortedGrouping() {
+ final ExecutionEnvironment env =
ExecutionEnvironment.getExecutionEnvironment();
+
+ TypeInformation[] types = new TypeInformation[]{Types.INT,
Types.INT};
+
+ String[] fieldNames = new String[]{"id", "value"};
+ RowTypeInfo rowTypeInfo = new RowTypeInfo(types, fieldNames);
+
+ UnsortedGrouping groupDs =
env.fromCollection(Collections.singleton(new Row(2)), rowTypeInfo).groupBy(0);
+
+ groupDs.maxBy(1);
+ groupDs.minBy(1);
--- End diff --
The tests pass because the program is not executed.
You would have to call `env.collect()` to run the program and compare the
returned result against the expected result. As I pointed out before, this will
fail, because the operator will cast the `Row` objects to `Tuple`.
---