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 . These examples are extracted from open source projects. 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
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 Project: flink   File: FieldAccessor.java    License: 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
@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 4
Source Project: flink   File: FieldAccessor.java    License: 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 5
Source Project: flink   File: DataSinkTest.java    License: 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 6
Source Project: flink   File: DataStreamPojoITCase.java    License: 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 7
@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 8
Source Project: flink   File: FieldAccessor.java    License: 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 9
Source Project: Flink-CEPplus   File: FieldAccessor.java    License: 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 10
Source Project: flink   File: FieldAccessorTest.java    License: 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 11
Source Project: flink   File: FieldAccessor.java    License: 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 12
Source Project: flink   File: FullOuterJoinOperatorTest.java    License: 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 Project: Flink-CEPplus   File: FieldAccessorTest.java    License: 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 14
@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 15
Source Project: flink   File: FullOuterJoinOperatorTest.java    License: 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 16
Source Project: flink   File: FieldAccessor.java    License: 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 17
Source Project: flink   File: DataSinkTest.java    License: 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 18
Source Project: flink   File: DataSinkTest.java    License: 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 19
@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 20
Source Project: flink   File: LeftOuterJoinOperatorTest.java    License: 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());
}