Search in sources :

Example 1 with CustomType

use of org.apache.flink.api.java.operator.JoinOperatorTest.CustomType in project flink by apache.

the class CoGroupOperatorTest method testCoGroupKeyExpressions4.

@Test(expected = IllegalArgumentException.class)
public void testCoGroupKeyExpressions4() {
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    DataSet<CustomType> ds1 = env.fromCollection(customTypeData);
    DataSet<CustomType> ds2 = env.fromCollection(customTypeData);
    // should not work, cogroup key non-existent
    ds1.coGroup(ds2).where("myNonExistent").equalTo("myInt");
}
Also used : CustomType(org.apache.flink.api.java.operator.JoinOperatorTest.CustomType) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) Test(org.junit.Test)

Example 2 with CustomType

use of org.apache.flink.api.java.operator.JoinOperatorTest.CustomType in project flink by apache.

the class CoGroupOperatorTest method testCoGroupKeyMixing3.

@Test(expected = InvalidProgramException.class)
public void testCoGroupKeyMixing3() {
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    DataSet<Tuple5<Integer, Long, String, Long, Integer>> ds1 = env.fromCollection(emptyTupleData, tupleTypeInfo);
    DataSet<CustomType> ds2 = env.fromCollection(customTypeData);
    // should not work, incompatible types
    ds1.coGroup(ds2).where(2).equalTo(new KeySelector<CustomType, Long>() {

        @Override
        public Long getKey(CustomType value) {
            return value.myLong;
        }
    });
}
Also used : CustomType(org.apache.flink.api.java.operator.JoinOperatorTest.CustomType) Tuple5(org.apache.flink.api.java.tuple.Tuple5) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) Test(org.junit.Test)

Example 3 with CustomType

use of org.apache.flink.api.java.operator.JoinOperatorTest.CustomType in project flink by apache.

the class CoGroupOperatorTest method testCoGroupKeyExpressions3Nested.

@Test(expected = InvalidProgramException.class)
public void testCoGroupKeyExpressions3Nested() {
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    DataSet<CustomType> ds1 = env.fromCollection(customTypeData);
    DataSet<CustomType> ds2 = env.fromCollection(customTypeData);
    // should not work, incompatible number of cogroup keys
    ds1.coGroup(ds2).where("nested.myInt", "nested.myString").equalTo("nested.myString");
}
Also used : CustomType(org.apache.flink.api.java.operator.JoinOperatorTest.CustomType) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) Test(org.junit.Test)

Example 4 with CustomType

use of org.apache.flink.api.java.operator.JoinOperatorTest.CustomType in project flink by apache.

the class CoGroupOperatorTest method testCoGroupKeyExpressions4Nested.

@Test(expected = IllegalArgumentException.class)
public void testCoGroupKeyExpressions4Nested() {
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    DataSet<CustomType> ds1 = env.fromCollection(customTypeData);
    DataSet<CustomType> ds2 = env.fromCollection(customTypeData);
    // should not work, cogroup key non-existent
    ds1.coGroup(ds2).where("nested.myNonExistent").equalTo("nested.myInt");
}
Also used : CustomType(org.apache.flink.api.java.operator.JoinOperatorTest.CustomType) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) Test(org.junit.Test)

Example 5 with CustomType

use of org.apache.flink.api.java.operator.JoinOperatorTest.CustomType in project flink by apache.

the class CoGroupOperatorTest method testCoGroupKeyAtomicExpression2.

@Test
public void testCoGroupKeyAtomicExpression2() {
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    DataSet<Integer> ds1 = env.fromElements(0, 0, 1);
    DataSet<CustomType> ds2 = env.fromCollection(customTypeData);
    ds1.coGroup(ds2).where("*").equalTo("myInt");
}
Also used : CustomType(org.apache.flink.api.java.operator.JoinOperatorTest.CustomType) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) Test(org.junit.Test)

Aggregations

ExecutionEnvironment (org.apache.flink.api.java.ExecutionEnvironment)20 CustomType (org.apache.flink.api.java.operator.JoinOperatorTest.CustomType)20 Test (org.junit.Test)20 InvalidProgramException (org.apache.flink.api.common.InvalidProgramException)5 Tuple5 (org.apache.flink.api.java.tuple.Tuple5)5 KeySelector (org.apache.flink.api.java.functions.KeySelector)2