Github user fhueske commented on a diff in the pull request:
https://github.com/apache/flink/pull/1585#discussion_r52099968
--- Diff:
flink-java/src/test/java/org/apache/flink/api/java/operator/SortPartitionTest.java
---
@@ -169,6 +169,72 @@ public void testSortPartitionWithExpressionKeys4() {
tupleDs.sortPartition("f3", Order.ASCENDING);
}
+ @Test
+ public void testSortPartitionWithKeySelector1() {
+ final ExecutionEnvironment env =
ExecutionEnvironment.getExecutionEnvironment();
+ DataSet<Tuple4<Integer, Long, CustomType, Long[]>> tupleDs =
env.fromCollection(tupleWithCustomData, tupleWithCustomInfo);
+
+ // should work
+ try {
+ tupleDs.sortPartition(new KeySelector<Tuple4<Integer,
Long, CustomType, Long[]>, Integer>() {
+ @Override
+ public Integer getKey(Tuple4<Integer, Long,
CustomType, Long[]> value) throws Exception {
+ return value.f0;
+ }
+ }, Order.ASCENDING);
+ } catch (Exception e) {
+ Assert.fail();
+ }
+ }
+
+ @Test(expected = InvalidProgramException.class)
+ public void testSortPartitionWithKeySelector2() {
+ final ExecutionEnvironment env =
ExecutionEnvironment.getExecutionEnvironment();
+ DataSet<Tuple4<Integer, Long, CustomType, Long[]>> tupleDs =
env.fromCollection(tupleWithCustomData, tupleWithCustomInfo);
+
+ // must not work
+ tupleDs.sortPartition(new KeySelector<Tuple4<Integer, Long,
CustomType, Long[]>, Long[]>() {
+ @Override
+ public Long[] getKey(Tuple4<Integer, Long, CustomType,
Long[]> value) throws Exception {
+ return value.f3;
+ }
+ }, Order.ASCENDING);
+ }
+
+ @Test(expected = InvalidProgramException.class)
--- End diff --
Can you add a test that first uses KeySelectors and then ExpressionKeys?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---