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

    https://github.com/apache/flink/pull/1138#discussion_r40441316
  
    --- Diff: 
flink-tests/src/test/java/org/apache/flink/test/javaApiOperators/OuterJoinITCase.java
 ---
    @@ -0,0 +1,679 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.flink.test.javaApiOperators;
    +
    +import org.apache.flink.api.common.InvalidProgramException;
    +import org.apache.flink.api.common.functions.FlatJoinFunction;
    +import org.apache.flink.api.common.functions.JoinFunction;
    +import org.apache.flink.api.common.functions.RichFlatJoinFunction;
    +import org.apache.flink.api.java.DataSet;
    +import org.apache.flink.api.java.ExecutionEnvironment;
    +import org.apache.flink.api.java.functions.KeySelector;
    +import org.apache.flink.api.java.tuple.Tuple2;
    +import org.apache.flink.api.java.tuple.Tuple3;
    +import org.apache.flink.api.java.tuple.Tuple5;
    +import org.apache.flink.api.java.tuple.Tuple6;
    +import org.apache.flink.api.java.tuple.Tuple7;
    +import org.apache.flink.configuration.Configuration;
    +import org.apache.flink.test.javaApiOperators.util.CollectionDataSets;
    +import 
org.apache.flink.test.javaApiOperators.util.CollectionDataSets.CustomType;
    +import org.apache.flink.test.javaApiOperators.util.CollectionDataSets.POJO;
    +import org.apache.flink.test.util.MultipleProgramsTestBase;
    +import org.apache.flink.util.Collector;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +import org.junit.runners.Parameterized;
    +
    +import java.util.Collection;
    +import java.util.List;
    +
    +@SuppressWarnings("serial")
    +@RunWith(Parameterized.class)
    +public class OuterJoinITCase extends MultipleProgramsTestBase {
    +
    +   public OuterJoinITCase(TestExecutionMode mode) {
    +           super(mode);
    +   }
    +
    +   @Test
    +   public void testUDFLeftOuterJoinOnTuplesWithKeyFieldPositions() throws 
Exception {
    +           /*
    +            * UDF Join on tuples with key field positions
    +            */
    +
    +           final ExecutionEnvironment env = 
ExecutionEnvironment.getExecutionEnvironment();
    +
    +           DataSet<Tuple3<Integer, Long, String>> ds1 = 
CollectionDataSets.getSmall3TupleDataSet(env);
    +           DataSet<Tuple5<Integer, Long, Integer, String, Long>> ds2 = 
CollectionDataSets.getSmall5TupleDataSet(env);
    +           DataSet<Tuple2<String, String>> joinDs =
    +                           ds1.leftOuterJoin(ds2)
    +                                           .where(0)
    +                                           .equalTo(0)
    +                                           .with(new T3T5FlatJoin());
    +
    +           List<Tuple2<String, String>> result = joinDs.collect();
    +
    +           String expected = "Hi,Hallo\n" +
    +                           "Hello,Hallo Welt\n" +
    +                           "Hello,Hallo Welt wie\n" +
    +                           "Hello world,null\n";
    +
    +           compareResultAsTuples(result, expected);
    +   }
    +
    +   @Test
    +   public void testUDFRightOuterJoinOnTuplesWithKeyFieldPositions() throws 
Exception {
    +           /*
    +            * UDF Join on tuples with key field positions
    +            */
    +
    +           final ExecutionEnvironment env = 
ExecutionEnvironment.getExecutionEnvironment();
    +
    +           DataSet<Tuple3<Integer, Long, String>> ds1 = 
CollectionDataSets.getSmall3TupleDataSet(env);
    +           DataSet<Tuple5<Integer, Long, Integer, String, Long>> ds2 = 
CollectionDataSets.getSmall5TupleDataSet(env);
    +           DataSet<Tuple2<String, String>> joinDs =
    +                           ds1.rightOuterJoin(ds2)
    +                                           .where(1)
    +                                           .equalTo(1)
    +                                           .with(new T3T5FlatJoin());
    +
    +           List<Tuple2<String, String>> result = joinDs.collect();
    +
    +           String expected = "Hi,Hallo\n" +
    +                           "Hello,Hallo Welt\n" +
    +                           "null,Hallo Welt wie\n" +
    +                           "Hello world,Hallo Welt\n";
    +
    +           compareResultAsTuples(result, expected);
    +   }
    +
    +   @Test
    +   public void testUDFFullOuterJoinOnTuplesWithKeyFieldPositions() throws 
Exception {
    +           /*
    +            * UDF Join on tuples with key field positions
    +            */
    +
    +           final ExecutionEnvironment env = 
ExecutionEnvironment.getExecutionEnvironment();
    +
    +           DataSet<Tuple3<Integer, Long, String>> ds1 = 
CollectionDataSets.getSmall3TupleDataSet(env);
    +           DataSet<Tuple5<Integer, Long, Integer, String, Long>> ds2 = 
CollectionDataSets.getSmall5TupleDataSet(env);
    +           DataSet<Tuple2<String, String>> joinDs =
    +                           ds1.fullOuterJoin(ds2)
    +                                           .where(0)
    +                                           .equalTo(2)
    +                                           .with(new T3T5FlatJoin());
    +
    +           List<Tuple2<String, String>> result = joinDs.collect();
    +
    +           String expected = "null,Hallo\n" +
    +                           "Hi,Hallo Welt\n" +
    +                           "Hello,Hallo Welt wie\n" +
    +                           "Hello world,null\n";
    +
    +           compareResultAsTuples(result, expected);
    +   }
    +
    +   @Test
    +   public void testUDFJoinOnTuplesWithMultipleKeyFieldPositions() throws 
Exception {
    +           /*
    +            * UDF Join on tuples with multiple key field positions
    +            */
    +
    +           final ExecutionEnvironment env = 
ExecutionEnvironment.getExecutionEnvironment();
    +
    +           DataSet<Tuple3<Integer, Long, String>> ds1 = 
CollectionDataSets.getSmall3TupleDataSet(env);
    +           DataSet<Tuple5<Integer, Long, Integer, String, Long>> ds2 = 
CollectionDataSets.getSmall5TupleDataSet(env);
    +           DataSet<Tuple2<String, String>> joinDs =
    +                           ds1.fullOuterJoin(ds2)
    +                                           .where(0, 1)
    +                                           .equalTo(0, 4)
    +                                           .with(new T3T5FlatJoin());
    +
    +           List<Tuple2<String, String>> result = joinDs.collect();
    +
    +           String expected = "Hi,Hallo\n" +
    +                           "Hello,Hallo Welt\n" +
    +                           "Hello world,null\n" +
    +                           "null,Hallo Welt wie\n";
    +
    +           compareResultAsTuples(result, expected);
    +   }
    +
    +   @Test(expected = InvalidProgramException.class)
    +   public void testDefaultJoin() throws Exception {
    --- End diff --
    
    This check should be done as a unit test (as mentioned in my other comment).


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to