use of org.apache.flink.table.types.logical.StructuredType.StructuredAttribute in project flink by apache.
the class DataTypeExtractorTest method getComplexPojoDataType.
/**
* Testing data type shared with the Scala tests.
*/
static DataType getComplexPojoDataType(Class<?> complexPojoClass, Class<?> simplePojoClass) {
final StructuredType.Builder builder = StructuredType.newBuilder(complexPojoClass);
builder.attributes(Arrays.asList(new StructuredAttribute("mapField", new MapType(VarCharType.STRING_TYPE, new IntType())), new StructuredAttribute("simplePojoField", getSimplePojoDataType(simplePojoClass).getLogicalType()), new StructuredAttribute("someObject", dummyRaw(Object.class).getLogicalType())));
builder.setFinal(true);
builder.setInstantiable(true);
final StructuredType structuredType = builder.build();
final List<DataType> fieldDataTypes = Arrays.asList(DataTypes.MAP(DataTypes.STRING(), DataTypes.INT()), getSimplePojoDataType(simplePojoClass), dummyRaw(Object.class));
return new FieldsDataType(structuredType, complexPojoClass, fieldDataTypes);
}
use of org.apache.flink.table.types.logical.StructuredType.StructuredAttribute in project flink by apache.
the class DataTypeExtractorTest method getOuterTupleDataType.
private static DataType getOuterTupleDataType() {
final StructuredType.Builder builder = StructuredType.newBuilder(Tuple2.class);
builder.attributes(Arrays.asList(new StructuredAttribute("f0", new IntType()), new StructuredAttribute("f1", getInnerTupleDataType().getLogicalType())));
builder.setFinal(true);
builder.setInstantiable(true);
final StructuredType structuredType = builder.build();
final List<DataType> fieldDataTypes = Arrays.asList(DataTypes.INT(), getInnerTupleDataType());
return new FieldsDataType(structuredType, Tuple2.class, fieldDataTypes);
}
use of org.apache.flink.table.types.logical.StructuredType.StructuredAttribute in project flink by apache.
the class StructuredRelDataType method create.
public static StructuredRelDataType create(FlinkTypeFactory factory, StructuredType structuredType) {
final List<RelDataTypeField> fields = new ArrayList<>();
for (int i = 0; i < structuredType.getAttributes().size(); i++) {
final StructuredAttribute attribute = structuredType.getAttributes().get(i);
final RelDataTypeField field = new RelDataTypeFieldImpl(attribute.getName(), i, factory.createFieldTypeFromLogicalType(attribute.getType()));
fields.add(field);
}
return new StructuredRelDataType(structuredType, fields);
}
use of org.apache.flink.table.types.logical.StructuredType.StructuredAttribute in project flink by apache.
the class DataTypeExtractorTest method getPojoWithRawSelfReferenceDataType.
private static DataType getPojoWithRawSelfReferenceDataType() {
final StructuredType.Builder builder = StructuredType.newBuilder(PojoWithRawSelfReference.class);
builder.attributes(Arrays.asList(new StructuredAttribute("integer", new IntType()), new StructuredAttribute("reference", dummyRaw(PojoWithRawSelfReference.class).getLogicalType())));
builder.setFinal(true);
builder.setInstantiable(true);
final StructuredType structuredType = builder.build();
final List<DataType> fieldDataTypes = Arrays.asList(DataTypes.INT(), dummyRaw(PojoWithRawSelfReference.class));
return new FieldsDataType(structuredType, PojoWithRawSelfReference.class, fieldDataTypes);
}
use of org.apache.flink.table.types.logical.StructuredType.StructuredAttribute in project flink by apache.
the class DataTypeExtractorTest method getInnerTupleDataType.
private static DataType getInnerTupleDataType() {
final StructuredType.Builder builder = StructuredType.newBuilder(Tuple2.class);
builder.attributes(Arrays.asList(new StructuredAttribute("f0", VarCharType.STRING_TYPE), new StructuredAttribute("f1", new BooleanType())));
builder.setFinal(true);
builder.setInstantiable(true);
final StructuredType structuredType = builder.build();
final List<DataType> fieldDataTypes = Arrays.asList(DataTypes.STRING(), DataTypes.BOOLEAN());
return new FieldsDataType(structuredType, Tuple2.class, fieldDataTypes);
}
Aggregations