Search in sources :

Example 81 with InvalidProgramException

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

the class CoGroupCustomPartitioningTest method testCoGroupWithTuplesWrongType.

@Test
public void testCoGroupWithTuplesWrongType() {
    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.coGroup(input2).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 82 with InvalidProgramException

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

the class CustomPartitioningTest method testPartitionPojoInvalidType.

@Test
public void testPartitionPojoInvalidType() {
    try {
        final int parallelism = 4;
        ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(parallelism);
        DataSet<Pojo> data = env.fromElements(new Pojo()).rebalance();
        try {
            data.partitionCustom(new TestPartitionerLong(), "a");
            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 83 with InvalidProgramException

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

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 84 with InvalidProgramException

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

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 85 with InvalidProgramException

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

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)

Aggregations

InvalidProgramException (org.apache.flink.api.common.InvalidProgramException)190 Test (org.junit.Test)108 ExecutionEnvironment (org.apache.flink.api.java.ExecutionEnvironment)102 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)42 Tuple3 (org.apache.flink.api.java.tuple.Tuple3)31 ArrayList (java.util.ArrayList)29 List (java.util.List)29 HashMap (java.util.HashMap)23 Map (java.util.Map)20 IOException (java.io.IOException)17 Tuple5 (org.apache.flink.api.java.tuple.Tuple5)16 TaskInfo (org.apache.flink.api.common.TaskInfo)15 RuntimeUDFContext (org.apache.flink.api.common.functions.util.RuntimeUDFContext)15 Ordering (org.apache.flink.api.common.operators.Ordering)12 LinkedHashSet (java.util.LinkedHashSet)10 Aggregator (org.apache.flink.api.common.aggregators.Aggregator)10 ConvergenceCriterion (org.apache.flink.api.common.aggregators.ConvergenceCriterion)10 Configuration (org.apache.flink.configuration.Configuration)10 Value (org.apache.flink.types.Value)10 InvalidTypesException (org.apache.flink.api.common.functions.InvalidTypesException)8