Java Code Examples for org.apache.flink.api.common.typeutils.CompositeType#InvalidFieldReferenceException

The following examples show how to use org.apache.flink.api.common.typeutils.CompositeType#InvalidFieldReferenceException . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FieldAccessorFactory.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private static FieldExpression decomposeFieldExpression(String fieldExpression) {
	Matcher matcher = PATTERN_NESTED_FIELDS_WILDCARD.matcher(fieldExpression);
	if (!matcher.matches()) {
		throw new CompositeType.InvalidFieldReferenceException("Invalid field expression \"" + fieldExpression + "\".");
	}

	String head = matcher.group(0);
	if (head.equals(Keys.ExpressionKeys.SELECT_ALL_CHAR) || head.equals(Keys.ExpressionKeys.SELECT_ALL_CHAR_SCALA)) {
		throw new CompositeType.InvalidFieldReferenceException("No wildcards are allowed here.");
	} else {
		head = matcher.group(1);
	}

	String tail = matcher.group(3);

	return new FieldExpression(head, tail);
}
 
Example 2
Source File: FieldAccessor.java    From flink with Apache License 2.0 6 votes vote down vote up
RecursiveProductFieldAccessor(int pos, TypeInformation<T> typeInfo, FieldAccessor<R, F> innerAccessor, ExecutionConfig config) {
	int arity = ((TupleTypeInfoBase) typeInfo).getArity();
	if (pos < 0 || pos >= arity) {
		throw new CompositeType.InvalidFieldReferenceException(
			"Tried to select " + ((Integer) pos).toString() + ". field on \"" +
				typeInfo.toString() + "\", which is an invalid index.");
	}
	checkNotNull(typeInfo, "typeInfo must not be null.");
	checkNotNull(innerAccessor, "innerAccessor must not be null.");

	this.pos = pos;
	this.serializer = (TupleSerializerBase<T>) typeInfo.createSerializer(config);
	this.length = this.serializer.getArity();
	this.fields = new Object[this.length];
	this.innerAccessor = innerAccessor;
	this.fieldType = innerAccessor.getFieldType();
}
 
Example 3
Source File: LeftOuterJoinOperatorTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test(expected = CompositeType.InvalidFieldReferenceException.class)
public void testLeftOuter8() {
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	DataSet<Tuple5<Integer, Long, String, Long, Integer>> ds1 = env.fromCollection(emptyTupleData, tupleTypeInfo);
	DataSet<Tuple5<Integer, Long, String, Long, Integer>> ds2 = env.fromCollection(emptyTupleData, tupleTypeInfo);

	// invalid key reference
	ds1.leftOuterJoin(ds2)
			.where(1).equalTo("f5")
			.with(new DummyJoin());
}
 
Example 4
Source File: DataStreamPojoITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test(expected = CompositeType.InvalidFieldReferenceException.class)
public void testFailOnNestedPojoFieldAccessor() throws Exception {
	StreamExecutionEnvironment see = StreamExecutionEnvironment.getExecutionEnvironment();

	DataStream<Data> dataStream = see.fromCollection(elements);
	dataStream.keyBy("aaa", "stats.count").sum("stats.nonExistingField");
}
 
Example 5
Source File: RightOuterJoinOperatorTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test(expected = CompositeType.InvalidFieldReferenceException.class)
public void testRightOuter8() {
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	DataSet<Tuple5<Integer, Long, String, Long, Integer>> ds1 = env.fromCollection(emptyTupleData, tupleTypeInfo);
	DataSet<Tuple5<Integer, Long, String, Long, Integer>> ds2 = env.fromCollection(emptyTupleData, tupleTypeInfo);

	// invalid key reference
	ds1.rightOuterJoin(ds2)
			.where(1).equalTo("f5")
			.with(new DummyJoin());
}
 
Example 6
Source File: DataSinkTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test(expected = CompositeType.InvalidFieldReferenceException.class)
public void testFailPojoInvalidField() {

	final ExecutionEnvironment env = ExecutionEnvironment
			.getExecutionEnvironment();
	DataSet<CustomType> pojoDs = env
			.fromCollection(pojoData);

	// must not work
	pojoDs.writeAsText("/tmp/willNotHappen")
		.sortLocalOutput("myInt", Order.ASCENDING)
		.sortLocalOutput("notThere", Order.DESCENDING);
}
 
Example 7
Source File: DataSinkTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test(expected = CompositeType.InvalidFieldReferenceException.class)
public void testFailTupleInv() {

	final ExecutionEnvironment env = ExecutionEnvironment
			.getExecutionEnvironment();
	DataSet<Tuple5<Integer, Long, String, Long, Integer>> tupleDs = env
			.fromCollection(emptyTupleData, tupleTypeInfo);

	// must not work
	tupleDs.writeAsText("/tmp/willNotHappen")
		.sortLocalOutput("notThere", Order.ASCENDING)
		.sortLocalOutput("f4", Order.DESCENDING);
}
 
Example 8
Source File: FieldAccessor.java    From flink with Apache License 2.0 5 votes vote down vote up
SimpleTupleFieldAccessor(int pos, TypeInformation<T> typeInfo) {
	checkNotNull(typeInfo, "typeInfo must not be null.");
	int arity = ((TupleTypeInfo) typeInfo).getArity();
	if (pos < 0 || pos >= arity) {
		throw new CompositeType.InvalidFieldReferenceException(
			"Tried to select " + ((Integer) pos).toString() + ". field on \"" +
			typeInfo.toString() + "\", which is an invalid index.");
	}

	this.pos = pos;
	this.fieldType = ((TupleTypeInfo) typeInfo).getTypeAt(pos);
}
 
Example 9
Source File: FullOuterJoinOperatorTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test(expected = CompositeType.InvalidFieldReferenceException.class)
public void testFullOuter8() {
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	DataSet<Tuple5<Integer, Long, String, Long, Integer>> ds1 = env.fromCollection(emptyTupleData, tupleTypeInfo);
	DataSet<Tuple5<Integer, Long, String, Long, Integer>> ds2 = env.fromCollection(emptyTupleData, tupleTypeInfo);

	// invalid key reference
	ds1.fullOuterJoin(ds2)
			.where(1).equalTo("f5")
			.with(new DummyJoin());
}
 
Example 10
Source File: RightOuterJoinOperatorTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test(expected = CompositeType.InvalidFieldReferenceException.class)
public void testRightOuter8() {
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	DataSet<Tuple5<Integer, Long, String, Long, Integer>> ds1 = env.fromCollection(emptyTupleData, tupleTypeInfo);
	DataSet<Tuple5<Integer, Long, String, Long, Integer>> ds2 = env.fromCollection(emptyTupleData, tupleTypeInfo);

	// invalid key reference
	ds1.rightOuterJoin(ds2)
			.where(1).equalTo("f5")
			.with(new DummyJoin());
}
 
Example 11
Source File: FieldAccessorTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test(expected = CompositeType.InvalidFieldReferenceException.class)
public void testIllegalFlatTuple() {
	Tuple2<String, Integer> t = Tuple2.of("aa", 5);
	TupleTypeInfo<Tuple2<String, Integer>> tpeInfo =
		(TupleTypeInfo<Tuple2<String, Integer>>) TypeExtractor.getForObject(t);

	FieldAccessorFactory.getAccessor(tpeInfo, "illegal", null);
}
 
Example 12
Source File: FullOuterJoinOperatorTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test(expected = CompositeType.InvalidFieldReferenceException.class)
public void testFullOuter8() {
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	DataSet<Tuple5<Integer, Long, String, Long, Integer>> ds1 = env.fromCollection(emptyTupleData, tupleTypeInfo);
	DataSet<Tuple5<Integer, Long, String, Long, Integer>> ds2 = env.fromCollection(emptyTupleData, tupleTypeInfo);

	// invalid key reference
	ds1.fullOuterJoin(ds2)
			.where(1).equalTo("f5")
			.with(new DummyJoin());
}
 
Example 13
Source File: FieldAccessor.java    From flink with Apache License 2.0 5 votes vote down vote up
public ArrayFieldAccessor(int pos, TypeInformation typeInfo) {
	if (pos < 0) {
		throw new CompositeType.InvalidFieldReferenceException("The " + ((Integer) pos).toString() + ". field selected on" +
			" an array, which is an invalid index.");
	}
	checkNotNull(typeInfo, "typeInfo must not be null.");

	this.pos = pos;
	this.fieldType = BasicTypeInfo.getInfoFor(typeInfo.getTypeClass().getComponentType());
}
 
Example 14
Source File: FieldAccessorTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test(expected = CompositeType.InvalidFieldReferenceException.class)
public void testIllegalTupleInPojoInTuple() {
	Tuple2<String, Foo> t = Tuple2.of("aa", new Foo(8, Tuple2.of("ddd", 9L), (short) 2));
	TupleTypeInfo<Tuple2<String, Foo>> tpeInfo =
		(TupleTypeInfo<Tuple2<String, Foo>>) TypeExtractor.getForObject(t);

	FieldAccessorFactory.getAccessor(tpeInfo, "illegal.illegal.illegal", null);
}
 
Example 15
Source File: FieldAccessor.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public ArrayFieldAccessor(int pos, TypeInformation typeInfo) {
	if (pos < 0) {
		throw new CompositeType.InvalidFieldReferenceException("The " + ((Integer) pos).toString() + ". field selected on" +
			" an array, which is an invalid index.");
	}
	checkNotNull(typeInfo, "typeInfo must not be null.");

	this.pos = pos;
	this.fieldType = BasicTypeInfo.getInfoFor(typeInfo.getTypeClass().getComponentType());
}
 
Example 16
Source File: FieldAccessor.java    From flink with Apache License 2.0 5 votes vote down vote up
SimpleProductFieldAccessor(int pos, TypeInformation<T> typeInfo, ExecutionConfig config) {
	checkNotNull(typeInfo, "typeInfo must not be null.");
	int arity = ((TupleTypeInfoBase) typeInfo).getArity();
	if (pos < 0 || pos >= arity) {
		throw new CompositeType.InvalidFieldReferenceException(
			"Tried to select " + ((Integer) pos).toString() + ". field on \"" +
				typeInfo.toString() + "\", which is an invalid index.");
	}

	this.pos = pos;
	this.fieldType = ((TupleTypeInfoBase<T>) typeInfo).getTypeAt(pos);
	this.serializer = (TupleSerializerBase<T>) typeInfo.createSerializer(config);
	this.length = this.serializer.getArity();
	this.fields = new Object[this.length];
}
 
Example 17
Source File: LeftOuterJoinOperatorTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test(expected = CompositeType.InvalidFieldReferenceException.class)
public void testLeftOuter8() {
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	DataSet<Tuple5<Integer, Long, String, Long, Integer>> ds1 = env.fromCollection(emptyTupleData, tupleTypeInfo);
	DataSet<Tuple5<Integer, Long, String, Long, Integer>> ds2 = env.fromCollection(emptyTupleData, tupleTypeInfo);

	// invalid key reference
	ds1.leftOuterJoin(ds2)
			.where(1).equalTo("f5")
			.with(new DummyJoin());
}
 
Example 18
Source File: DataStreamPojoITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test(expected = CompositeType.InvalidFieldReferenceException.class)
public void testFailOnNestedPojoFieldAccessor() throws Exception {
	StreamExecutionEnvironment see = StreamExecutionEnvironment.getExecutionEnvironment();

	DataStream<Data> dataStream = see.fromCollection(elements);
	dataStream.keyBy("aaa", "stats.count").sum("stats.nonExistingField");
}
 
Example 19
Source File: DataSinkTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test(expected = CompositeType.InvalidFieldReferenceException.class)
public void testFailPojoInvalidField() {

	final ExecutionEnvironment env = ExecutionEnvironment
			.getExecutionEnvironment();
	DataSet<CustomType> pojoDs = env
			.fromCollection(pojoData);

	// must not work
	pojoDs.writeAsText("/tmp/willNotHappen")
		.sortLocalOutput("myInt", Order.ASCENDING)
		.sortLocalOutput("notThere", Order.DESCENDING);
}
 
Example 20
Source File: FieldAccessor.java    From flink with Apache License 2.0 5 votes vote down vote up
SimpleProductFieldAccessor(int pos, TypeInformation<T> typeInfo, ExecutionConfig config) {
	checkNotNull(typeInfo, "typeInfo must not be null.");
	int arity = ((TupleTypeInfoBase) typeInfo).getArity();
	if (pos < 0 || pos >= arity) {
		throw new CompositeType.InvalidFieldReferenceException(
			"Tried to select " + ((Integer) pos).toString() + ". field on \"" +
				typeInfo.toString() + "\", which is an invalid index.");
	}

	this.pos = pos;
	this.fieldType = ((TupleTypeInfoBase<T>) typeInfo).getTypeAt(pos);
	this.serializer = (TupleSerializerBase<T>) typeInfo.createSerializer(config);
	this.length = this.serializer.getArity();
	this.fields = new Object[this.length];
}