Search in sources :

Example 11 with CustomType

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

the class CoGroupOperatorTest method testCoGroupKeyExpressions1.

@Test
public void testCoGroupKeyExpressions1() {
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    DataSet<CustomType> ds1 = env.fromCollection(customTypeData);
    DataSet<CustomType> ds2 = env.fromCollection(customTypeData);
    // should work
    try {
        ds1.coGroup(ds2).where("myInt").equalTo("myInt");
    } catch (Exception e) {
        Assert.fail();
    }
}
Also used : CustomType(org.apache.flink.api.java.operator.JoinOperatorTest.CustomType) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) InvalidProgramException(org.apache.flink.api.common.InvalidProgramException) Test(org.junit.Test)

Example 12 with CustomType

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

the class CoGroupOperatorTest method testCoGroupKeyExpressions2Nested.

@Test(expected = InvalidProgramException.class)
public void testCoGroupKeyExpressions2Nested() {
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    DataSet<CustomType> ds1 = env.fromCollection(customTypeData);
    DataSet<CustomType> ds2 = env.fromCollection(customTypeData);
    // should not work, incompatible cogroup key types
    ds1.coGroup(ds2).where("nested.myInt").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 13 with CustomType

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

the class CoGroupOperatorTest method testCoGroupKeyExpressions2.

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

Example 14 with CustomType

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

the class CoGroupOperatorTest method testCoGroupKeyAtomicInvalidExpression1.

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

Example 15 with CustomType

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

the class CoGroupOperatorTest method testCoGroupKeyAtomicExpression1.

@Test
public void testCoGroupKeyAtomicExpression1() {
    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("*");
}
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