Search in sources :

Example 16 with CustomType

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

the class CoGroupOperatorTest method testCoGroupKeyAtomicInvalidExpression4.

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

Example 17 with CustomType

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

the class CoGroupOperatorTest method testCoGroupKeyMixing1.

@Test
public void testCoGroupKeyMixing1() {
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    DataSet<CustomType> ds1 = env.fromCollection(customTypeData);
    DataSet<Tuple5<Integer, Long, String, Long, Integer>> ds2 = env.fromCollection(emptyTupleData, tupleTypeInfo);
    // should work
    try {
        ds1.coGroup(ds2).where(new KeySelector<CustomType, Long>() {

            @Override
            public Long getKey(CustomType value) {
                return value.myLong;
            }
        }).equalTo(3);
    } catch (Exception e) {
        Assert.fail();
    }
}
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) KeySelector(org.apache.flink.api.java.functions.KeySelector) InvalidProgramException(org.apache.flink.api.common.InvalidProgramException) Test(org.junit.Test)

Example 18 with CustomType

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

the class CoGroupOperatorTest method testCoGroupKeyFields6.

@Test(expected = InvalidProgramException.class)
public void testCoGroupKeyFields6() {
    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, cogroup key fields on custom type
    ds1.coGroup(ds2).where(4).equalTo(0);
}
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 19 with CustomType

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

the class CoGroupOperatorTest method testCoGroupKeyAtomicInvalidExpression3.

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

Example 20 with CustomType

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

the class CoGroupOperatorTest method testCoGroupKeyMixing4.

@Test(expected = InvalidProgramException.class)
public void testCoGroupKeyMixing4() {
    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, more than one key field position
    ds1.coGroup(ds2).where(1, 3).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)

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