Search in sources :

Example 81 with ExecutionEnvironment

use of org.apache.flink.api.java.ExecutionEnvironment 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 82 with ExecutionEnvironment

use of org.apache.flink.api.java.ExecutionEnvironment 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 83 with ExecutionEnvironment

use of org.apache.flink.api.java.ExecutionEnvironment in project flink by apache.

the class CoGroupOperatorTest method testCoGroupKeyAtomicInvalidExpression2.

@Test(expected = InvalidProgramException.class)
public void testCoGroupKeyAtomicInvalidExpression2() {
    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 84 with ExecutionEnvironment

use of org.apache.flink.api.java.ExecutionEnvironment in project flink by apache.

the class CoGroupOperatorTest method testCoGroupKeyExpressions1Nested.

@Test
public void testCoGroupKeyExpressions1Nested() {
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    DataSet<CustomType> ds1 = env.fromCollection(customTypeData);
    DataSet<CustomType> ds2 = env.fromCollection(customTypeData);
    // should work
    try {
        ds1.coGroup(ds2).where("nested.myInt").equalTo("nested.myInt");
    } catch (Exception e) {
        e.printStackTrace();
        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 85 with ExecutionEnvironment

use of org.apache.flink.api.java.ExecutionEnvironment in project flink by apache.

the class CoGroupOperatorTest method testCoGroupKeyMixing2.

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

            @Override
            public Long getKey(CustomType value) {
                return value.myLong;
            }
        });
    } 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) InvalidProgramException(org.apache.flink.api.common.InvalidProgramException) Test(org.junit.Test)

Aggregations

ExecutionEnvironment (org.apache.flink.api.java.ExecutionEnvironment)1247 Test (org.junit.Test)1090 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)374 Tuple3 (org.apache.flink.api.java.tuple.Tuple3)264 Plan (org.apache.flink.api.common.Plan)238 Tuple5 (org.apache.flink.api.java.tuple.Tuple5)236 OptimizedPlan (org.apache.flink.optimizer.plan.OptimizedPlan)199 SinkPlanNode (org.apache.flink.optimizer.plan.SinkPlanNode)139 InvalidProgramException (org.apache.flink.api.common.InvalidProgramException)138 Vertex (org.apache.flink.graph.Vertex)93 SingleInputPlanNode (org.apache.flink.optimizer.plan.SingleInputPlanNode)73 Edge (org.apache.flink.graph.Edge)70 DualInputPlanNode (org.apache.flink.optimizer.plan.DualInputPlanNode)66 ArrayList (java.util.ArrayList)57 Tuple1 (org.apache.flink.api.java.tuple.Tuple1)49 SourcePlanNode (org.apache.flink.optimizer.plan.SourcePlanNode)44 DiscardingOutputFormat (org.apache.flink.api.java.io.DiscardingOutputFormat)39 BatchTableEnvironment (org.apache.flink.table.api.java.BatchTableEnvironment)38 FieldSet (org.apache.flink.api.common.operators.util.FieldSet)37 JobGraphGenerator (org.apache.flink.optimizer.plantranslate.JobGraphGenerator)35