Search in sources :

Example 21 with InvalidProgramException

use of org.apache.flink.api.common.InvalidProgramException in project flink by apache.

the class GroupingPojoTranslationTest method testCustomPartitioningTupleInvalidTypeSorted.

@Test
public void testCustomPartitioningTupleInvalidTypeSorted() {
    try {
        ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
        DataSet<Pojo3> data = env.fromElements(new Pojo3()).rebalance().setParallelism(4);
        try {
            data.groupBy("a").sortGroup("b", Order.ASCENDING).withPartitioner(new TestPartitionerLong());
            fail("Should throw an exception");
        } catch (InvalidProgramException e) {
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) InvalidProgramException(org.apache.flink.api.common.InvalidProgramException) InvalidProgramException(org.apache.flink.api.common.InvalidProgramException) Test(org.junit.Test)

Example 22 with InvalidProgramException

use of org.apache.flink.api.common.InvalidProgramException in project flink by apache.

the class JoinCustomPartitioningTest method testJoinWithKeySelectorsWrongType.

@Test
public void testJoinWithKeySelectorsWrongType() {
    try {
        final Partitioner<Long> partitioner = new TestPartitionerLong();
        ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
        DataSet<Pojo2> input1 = env.fromElements(new Pojo2());
        DataSet<Pojo3> input2 = env.fromElements(new Pojo3());
        try {
            input1.join(input2, JoinHint.REPARTITION_HASH_FIRST).where(new Pojo2KeySelector()).equalTo(new Pojo3KeySelector()).withPartitioner(partitioner);
            fail("should throw an exception");
        } catch (InvalidProgramException e) {
        // expected
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) InvalidProgramException(org.apache.flink.api.common.InvalidProgramException) InvalidProgramException(org.apache.flink.api.common.InvalidProgramException) Test(org.junit.Test)

Example 23 with InvalidProgramException

use of org.apache.flink.api.common.InvalidProgramException in project flink by apache.

the class JoinCustomPartitioningTest method testJoinWithTuplesWrongType.

@Test
public void testJoinWithTuplesWrongType() {
    try {
        final Partitioner<Integer> partitioner = new TestPartitionerInt();
        ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
        DataSet<Tuple2<Long, Long>> input1 = env.fromElements(new Tuple2<Long, Long>(0L, 0L));
        DataSet<Tuple3<Long, Long, Long>> input2 = env.fromElements(new Tuple3<Long, Long, Long>(0L, 0L, 0L));
        try {
            input1.join(input2, JoinHint.REPARTITION_HASH_FIRST).where(1).equalTo(0).withPartitioner(partitioner);
            fail("should throw an exception");
        } catch (InvalidProgramException e) {
        // expected
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) InvalidProgramException(org.apache.flink.api.common.InvalidProgramException) InvalidProgramException(org.apache.flink.api.common.InvalidProgramException) Tuple2(org.apache.flink.api.java.tuple.Tuple2) Tuple3(org.apache.flink.api.java.tuple.Tuple3) Test(org.junit.Test)

Example 24 with InvalidProgramException

use of org.apache.flink.api.common.InvalidProgramException in project flink by apache.

the class CoGroupCustomPartitioningTest method testCoGroupWithPojosWrongType.

@Test
public void testCoGroupWithPojosWrongType() {
    try {
        final Partitioner<Long> partitioner = new TestPartitionerLong();
        ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
        DataSet<Pojo2> input1 = env.fromElements(new Pojo2());
        DataSet<Pojo3> input2 = env.fromElements(new Pojo3());
        try {
            input1.coGroup(input2).where("a").equalTo("b").withPartitioner(partitioner);
            fail("should throw an exception");
        } catch (InvalidProgramException e) {
        // expected
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) InvalidProgramException(org.apache.flink.api.common.InvalidProgramException) InvalidProgramException(org.apache.flink.api.common.InvalidProgramException) Test(org.junit.Test)

Example 25 with InvalidProgramException

use of org.apache.flink.api.common.InvalidProgramException in project flink by apache.

the class CustomPartitioningTest method testPartitionTuplesInvalidType.

@Test
public void testPartitionTuplesInvalidType() {
    try {
        final int parallelism = 4;
        ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(parallelism);
        DataSet<Tuple2<Integer, Integer>> data = env.fromElements(new Tuple2<Integer, Integer>(0, 0)).rebalance();
        try {
            data.partitionCustom(new TestPartitionerLong(), 0);
            fail("Should throw an exception");
        } catch (InvalidProgramException e) {
        // expected
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) InvalidProgramException(org.apache.flink.api.common.InvalidProgramException) Tuple2(org.apache.flink.api.java.tuple.Tuple2) InvalidProgramException(org.apache.flink.api.common.InvalidProgramException) Test(org.junit.Test)

Aggregations

InvalidProgramException (org.apache.flink.api.common.InvalidProgramException)65 Test (org.junit.Test)38 ExecutionEnvironment (org.apache.flink.api.java.ExecutionEnvironment)36 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)16 ArrayList (java.util.ArrayList)12 List (java.util.List)12 Tuple3 (org.apache.flink.api.java.tuple.Tuple3)11 HashMap (java.util.HashMap)9 Map (java.util.Map)8 IOException (java.io.IOException)7 TaskInfo (org.apache.flink.api.common.TaskInfo)6 RuntimeUDFContext (org.apache.flink.api.common.functions.util.RuntimeUDFContext)6 Tuple5 (org.apache.flink.api.java.tuple.Tuple5)6 LinkedHashSet (java.util.LinkedHashSet)4 Aggregator (org.apache.flink.api.common.aggregators.Aggregator)4 ConvergenceCriterion (org.apache.flink.api.common.aggregators.ConvergenceCriterion)4 KeySelector (org.apache.flink.api.java.functions.KeySelector)4 InvalidTypesException (org.apache.flink.api.common.functions.InvalidTypesException)3 Configuration (org.apache.flink.configuration.Configuration)3 MetricGroup (org.apache.flink.metrics.MetricGroup)3