use of org.apache.flink.api.common.InvalidProgramException in project flink by apache.
the class LocalEnvironment method validateAndGetConfiguration.
private static Configuration validateAndGetConfiguration(final Configuration configuration) {
if (!ExecutionEnvironment.areExplicitEnvironmentsAllowed()) {
throw new InvalidProgramException("The LocalEnvironment cannot be instantiated when running in a pre-defined context " + "(such as Command Line Client or TestEnvironment)");
}
final Configuration effectiveConfiguration = new Configuration(checkNotNull(configuration));
effectiveConfiguration.set(DeploymentOptions.TARGET, "local");
effectiveConfiguration.set(DeploymentOptions.ATTACHED, true);
return effectiveConfiguration;
}
use of org.apache.flink.api.common.InvalidProgramException in project flink by apache.
the class AggregateOperatorTest method testFieldsAggregate.
@Test
public void testFieldsAggregate() {
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env.fromCollection(emptyTupleData, tupleTypeInfo);
// should work
try {
tupleDs.aggregate(Aggregations.SUM, 1);
} catch (Exception e) {
Assert.fail();
}
// should not work: index out of bounds
try {
tupleDs.aggregate(Aggregations.SUM, 10);
Assert.fail();
} catch (IllegalArgumentException iae) {
// we're good here
} catch (Exception e) {
Assert.fail();
}
// should not work: not applied to tuple dataset
DataSet<Long> longDs = env.fromCollection(emptyLongData, BasicTypeInfo.LONG_TYPE_INFO);
try {
longDs.aggregate(Aggregations.MIN, 1);
Assert.fail();
} catch (InvalidProgramException uoe) {
// we're good here
} catch (Exception e) {
Assert.fail();
}
}
use of org.apache.flink.api.common.InvalidProgramException in project flink by apache.
the class FirstNOperatorTest method testGroupedFirstN.
@Test
public void testGroupedFirstN() {
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env.fromCollection(emptyTupleData, tupleTypeInfo);
// should work
try {
tupleDs.groupBy(2).first(1);
} catch (Exception e) {
Assert.fail();
}
// should work
try {
tupleDs.groupBy(1, 3).first(10);
} catch (Exception e) {
Assert.fail();
}
// should not work n == 0
try {
tupleDs.groupBy(0).first(0);
Assert.fail();
} catch (InvalidProgramException ipe) {
// we're good here
} catch (Exception e) {
Assert.fail();
}
// should not work n == -1
try {
tupleDs.groupBy(2).first(-1);
Assert.fail();
} catch (InvalidProgramException ipe) {
// we're good here
} catch (Exception e) {
Assert.fail();
}
}
use of org.apache.flink.api.common.InvalidProgramException in project flink by apache.
the class GroupingKeySelectorTranslationTest method testCustomPartitioningTupleRejectCompositeKey.
@Test
public void testCustomPartitioningTupleRejectCompositeKey() {
try {
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple3<Integer, Integer, Integer>> data = env.fromElements(new Tuple3<Integer, Integer, Integer>(0, 0, 0)).rebalance().setParallelism(4);
try {
data.groupBy(new TestBinaryKeySelector<Tuple3<Integer, Integer, Integer>>()).withPartitioner(new TestPartitionerInt());
fail("Should throw an exception");
} catch (InvalidProgramException e) {
}
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.apache.flink.api.common.InvalidProgramException in project flink by apache.
the class GroupingKeySelectorTranslationTest method testCustomPartitioningKeySelectorInvalidTypeSorted.
@Test
public void testCustomPartitioningKeySelectorInvalidTypeSorted() {
try {
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple3<Integer, Integer, Integer>> data = env.fromElements(new Tuple3<Integer, Integer, Integer>(0, 0, 0)).rebalance().setParallelism(4);
try {
data.groupBy(new TestKeySelector<Tuple3<Integer, Integer, Integer>>()).sortGroup(1, Order.ASCENDING).withPartitioner(new TestPartitionerLong());
fail("Should throw an exception");
} catch (InvalidProgramException e) {
}
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
Aggregations