[ 
https://issues.apache.org/jira/browse/FLINK-2998?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15241491#comment-15241491
 ] 

ASF GitHub Bot commented on FLINK-2998:
---------------------------------------

Github user fhueske commented on a diff in the pull request:

    https://github.com/apache/flink/pull/1838#discussion_r59752067
  
    --- Diff: 
flink-tests/src/test/java/org/apache/flink/test/javaApiOperators/CustomDistributionITCase.java
 ---
    @@ -175,6 +175,77 @@ else if (pIdx > 0 && pIdx < dist.getParallelism() - 1) 
{
                env.execute();
        }
     
    +   @Test
    +   public void testPartitionKeyLessDistribution() throws Exception{
    +           /*
    +            * Test the number of keys less than the number of distribution 
fields
    +            */
    +
    +           ExecutionEnvironment env = 
ExecutionEnvironment.createLocalEnvironment();
    +
    +           DataSet<Tuple3<Integer, Long, String>> input1 = 
CollectionDataSets.get3TupleDataSet(env);
    +           final TestDataDist2 dist = new TestDataDist2();
    +
    +           env.setParallelism(dist.getParallelism());
    +
    +           DataSet<Boolean> result = DataSetUtils
    +                           .partitionByRange(input1, dist, 0)
    +                           .mapPartition(new 
RichMapPartitionFunction<Tuple3<Integer, Long, String>, Boolean>() {
    +
    +                                                             @Override
    +                                                             public void 
mapPartition(Iterable<Tuple3<Integer, Long, String>> values, Collector<Boolean> 
out) throws Exception {
    +                                                                     int 
pIdx = getRuntimeContext().getIndexOfThisSubtask();
    +
    +                                                                     for 
(Tuple3<Integer, Long, String> s : values) {
    +                                                                           
  boolean correctlyPartitioned = true;
    +                                                                           
  if (pIdx == 0) {
    +                                                                           
          Integer[] upper = dist.boundaries[0];
    +                                                                           
          if (s.f0.compareTo(upper[0]) > 0) {
    +                                                                           
                  correctlyPartitioned = false;
    +                                                                           
          }
    +                                                                           
  } else if (pIdx > 0 && pIdx < dist.getParallelism() - 1) {
    +                                                                           
          Integer[] lower = dist.boundaries[pIdx - 1];
    +                                                                           
          Integer[] upper = dist.boundaries[pIdx];
    +                                                                           
          if (s.f0.compareTo(upper[0]) > 0 || (s.f0.compareTo(lower[0]) <= 0)) {
    +                                                                           
                  correctlyPartitioned = false;
    +                                                                           
          }
    +                                                                           
  } else {
    +                                                                           
          Integer[] lower = dist.boundaries[pIdx - 1];
    +                                                                           
          if ((s.f0.compareTo(lower[0]) <= 0)) {
    +                                                                           
                  correctlyPartitioned = false;
    +                                                                           
          }
    +                                                                           
  }
    +
    +                                                                           
  if (!correctlyPartitioned) {
    +                                                                           
          fail("Record was not correctly partitioned: " + s.toString());
    +                                                                           
  }
    +                                                                     }
    +                                                             }
    +                                                     }
    +                           );
    +
    +           result.output(new DiscardingOutputFormat<Boolean>());
    +           env.execute();
    +   }
    +
    +   @Test(expected = IllegalArgumentException.class)
    +   public void testPartitionMoreThanDistribution() throws Exception{
    +           /*
    +            * Test the number of keys larger than the number of 
distribution fields
    +            */
    +
    +           ExecutionEnvironment env = 
ExecutionEnvironment.createLocalEnvironment();
    +
    +           DataSet<Tuple3<Integer, Long, String>> input1 = 
CollectionDataSets.get3TupleDataSet(env);
    +           final TestDataDist2 dist = new TestDataDist2();
    +
    +           DataSet<Tuple3<Integer, Long, String>> result = DataSetUtils
    +                           .partitionByRange(input1, dist, 0, 1, 2);
    +
    +           result.output(new DiscardingOutputFormat<Tuple3<Integer, Long, 
String>>());
    --- End diff --
    
    I think you can remove this code. The test should fail at 
`partitionByRange(...)`, right?


> Support range partition comparison for multi input nodes.
> ---------------------------------------------------------
>
>                 Key: FLINK-2998
>                 URL: https://issues.apache.org/jira/browse/FLINK-2998
>             Project: Flink
>          Issue Type: New Feature
>          Components: Optimizer
>            Reporter: Chengxiang Li
>            Priority: Minor
>
> The optimizer may have potential opportunity to optimize the DAG while it 
> found two input range partition are equivalent, we does not support the 
> comparison yet.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to