use of org.apache.flink.table.types.logical.VarCharType in project flink by apache.
the class ArrowUtilsTest method init.
@BeforeClass
public static void init() {
testFields = new ArrayList<>();
testFields.add(Tuple5.of("f1", new TinyIntType(), new ArrowType.Int(8, true), TinyIntWriter.TinyIntWriterForRow.class, ArrowTinyIntColumnVector.class));
testFields.add(Tuple5.of("f2", new SmallIntType(), new ArrowType.Int(8 * 2, true), SmallIntWriter.SmallIntWriterForRow.class, ArrowSmallIntColumnVector.class));
testFields.add(Tuple5.of("f3", new IntType(), new ArrowType.Int(8 * 4, true), IntWriter.IntWriterForRow.class, ArrowIntColumnVector.class));
testFields.add(Tuple5.of("f4", new BigIntType(), new ArrowType.Int(8 * 8, true), BigIntWriter.BigIntWriterForRow.class, ArrowBigIntColumnVector.class));
testFields.add(Tuple5.of("f5", new BooleanType(), new ArrowType.Bool(), BooleanWriter.BooleanWriterForRow.class, ArrowBooleanColumnVector.class));
testFields.add(Tuple5.of("f6", new FloatType(), new ArrowType.FloatingPoint(FloatingPointPrecision.SINGLE), FloatWriter.FloatWriterForRow.class, ArrowFloatColumnVector.class));
testFields.add(Tuple5.of("f7", new DoubleType(), new ArrowType.FloatingPoint(FloatingPointPrecision.DOUBLE), DoubleWriter.DoubleWriterForRow.class, ArrowDoubleColumnVector.class));
testFields.add(Tuple5.of("f8", new VarCharType(), ArrowType.Utf8.INSTANCE, VarCharWriter.VarCharWriterForRow.class, ArrowVarCharColumnVector.class));
testFields.add(Tuple5.of("f9", new VarBinaryType(), ArrowType.Binary.INSTANCE, VarBinaryWriter.VarBinaryWriterForRow.class, ArrowVarBinaryColumnVector.class));
testFields.add(Tuple5.of("f10", new DecimalType(10, 3), new ArrowType.Decimal(10, 3), DecimalWriter.DecimalWriterForRow.class, ArrowDecimalColumnVector.class));
testFields.add(Tuple5.of("f11", new DateType(), new ArrowType.Date(DateUnit.DAY), DateWriter.DateWriterForRow.class, ArrowDateColumnVector.class));
testFields.add(Tuple5.of("f13", new TimeType(0), new ArrowType.Time(TimeUnit.SECOND, 32), TimeWriter.TimeWriterForRow.class, ArrowTimeColumnVector.class));
testFields.add(Tuple5.of("f14", new TimeType(2), new ArrowType.Time(TimeUnit.MILLISECOND, 32), TimeWriter.TimeWriterForRow.class, ArrowTimeColumnVector.class));
testFields.add(Tuple5.of("f15", new TimeType(4), new ArrowType.Time(TimeUnit.MICROSECOND, 64), TimeWriter.TimeWriterForRow.class, ArrowTimeColumnVector.class));
testFields.add(Tuple5.of("f16", new TimeType(8), new ArrowType.Time(TimeUnit.NANOSECOND, 64), TimeWriter.TimeWriterForRow.class, ArrowTimeColumnVector.class));
testFields.add(Tuple5.of("f17", new LocalZonedTimestampType(0), new ArrowType.Timestamp(TimeUnit.SECOND, null), TimestampWriter.TimestampWriterForRow.class, ArrowTimestampColumnVector.class));
testFields.add(Tuple5.of("f18", new LocalZonedTimestampType(2), new ArrowType.Timestamp(TimeUnit.MILLISECOND, null), TimestampWriter.TimestampWriterForRow.class, ArrowTimestampColumnVector.class));
testFields.add(Tuple5.of("f19", new LocalZonedTimestampType(4), new ArrowType.Timestamp(TimeUnit.MICROSECOND, null), TimestampWriter.TimestampWriterForRow.class, ArrowTimestampColumnVector.class));
testFields.add(Tuple5.of("f20", new LocalZonedTimestampType(8), new ArrowType.Timestamp(TimeUnit.NANOSECOND, null), TimestampWriter.TimestampWriterForRow.class, ArrowTimestampColumnVector.class));
testFields.add(Tuple5.of("f21", new TimestampType(0), new ArrowType.Timestamp(TimeUnit.SECOND, null), TimestampWriter.TimestampWriterForRow.class, ArrowTimestampColumnVector.class));
testFields.add(Tuple5.of("f22", new TimestampType(2), new ArrowType.Timestamp(TimeUnit.MILLISECOND, null), TimestampWriter.TimestampWriterForRow.class, ArrowTimestampColumnVector.class));
testFields.add(Tuple5.of("f23", new TimestampType(4), new ArrowType.Timestamp(TimeUnit.MICROSECOND, null), TimestampWriter.TimestampWriterForRow.class, ArrowTimestampColumnVector.class));
testFields.add(Tuple5.of("f24", new TimestampType(8), new ArrowType.Timestamp(TimeUnit.NANOSECOND, null), TimestampWriter.TimestampWriterForRow.class, ArrowTimestampColumnVector.class));
testFields.add(Tuple5.of("f25", new ArrayType(new VarCharType()), ArrowType.List.INSTANCE, ArrayWriter.ArrayWriterForRow.class, ArrowArrayColumnVector.class));
RowType rowFieldType = new RowType(Arrays.asList(new RowType.RowField("a", new IntType()), new RowType.RowField("b", new VarCharType()), new RowType.RowField("c", new ArrayType(new VarCharType())), new RowType.RowField("d", new TimestampType(2)), new RowType.RowField("e", new RowType((Arrays.asList(new RowType.RowField("e1", new IntType()), new RowType.RowField("e2", new VarCharType())))))));
testFields.add(Tuple5.of("f26", rowFieldType, ArrowType.Struct.INSTANCE, RowWriter.RowWriterForRow.class, ArrowRowColumnVector.class));
List<RowType.RowField> rowFields = new ArrayList<>();
for (Tuple5<String, LogicalType, ArrowType, Class<?>, Class<?>> field : testFields) {
rowFields.add(new RowType.RowField(field.f0, field.f1));
}
rowType = new RowType(rowFields);
allocator = ArrowUtils.getRootAllocator().newChildAllocator("stdout", 0, Long.MAX_VALUE);
}
use of org.apache.flink.table.types.logical.VarCharType in project flink by apache.
the class ArrowSourceFunctionTest method init.
@BeforeClass
public static void init() {
fieldTypes.add(new VarCharType());
List<RowType.RowField> rowFields = new ArrayList<>();
for (int i = 0; i < fieldTypes.size(); i++) {
rowFields.add(new RowType.RowField("f" + i, fieldTypes.get(i)));
}
rowType = new RowType(rowFields);
dataType = TypeConversions.fromLogicalToDataType(rowType);
serializer = new RowDataSerializer(fieldTypes.toArray(new LogicalType[0]));
allocator = ArrowUtils.getRootAllocator().newChildAllocator("stdout", 0, Long.MAX_VALUE);
}
use of org.apache.flink.table.types.logical.VarCharType in project flink by apache.
the class PythonScalarFunctionOperatorTestBase method getTestHarness.
private OneInputStreamOperatorTestHarness<IN, OUT> getTestHarness(Configuration config) throws Exception {
RowType dataType = new RowType(Arrays.asList(new RowType.RowField("f1", new VarCharType()), new RowType.RowField("f2", new VarCharType()), new RowType.RowField("f3", new BigIntType())));
AbstractPythonScalarFunctionOperator operator = getTestOperator(config, new PythonFunctionInfo[] { new PythonFunctionInfo(DummyPythonFunction.INSTANCE, new Integer[] { 0 }) }, dataType, dataType, new int[] { 2 }, new int[] { 0, 1 });
OneInputStreamOperatorTestHarness<IN, OUT> testHarness = new OneInputStreamOperatorTestHarness(operator);
testHarness.getStreamConfig().setManagedMemoryFractionOperatorOfUseCase(ManagedMemoryUseCase.PYTHON, 0.5);
testHarness.setup(getOutputTypeSerializer(dataType));
return testHarness;
}
use of org.apache.flink.table.types.logical.VarCharType in project flink by apache.
the class RelDataTypeJsonSerdeTest method testRelDataTypeSerde.
// --------------------------------------------------------------------------------------------
// Test data
// --------------------------------------------------------------------------------------------
public static List<RelDataType> testRelDataTypeSerde() {
// the values in the list do not care about nullable.
final List<RelDataType> types = Arrays.asList(FACTORY.createSqlType(SqlTypeName.BOOLEAN), FACTORY.createSqlType(SqlTypeName.TINYINT), FACTORY.createSqlType(SqlTypeName.SMALLINT), FACTORY.createSqlType(SqlTypeName.INTEGER), FACTORY.createSqlType(SqlTypeName.BIGINT), FACTORY.createSqlType(SqlTypeName.DECIMAL, 10, 3), FACTORY.createSqlType(SqlTypeName.DECIMAL, 19, 0), FACTORY.createSqlType(SqlTypeName.DECIMAL, 38, 19), FACTORY.createSqlType(SqlTypeName.FLOAT), FACTORY.createSqlType(SqlTypeName.DOUBLE), FACTORY.createSqlType(SqlTypeName.DATE), FACTORY.createSqlType(SqlTypeName.TIME), FACTORY.createSqlType(SqlTypeName.TIMESTAMP), FACTORY.createSqlType(SqlTypeName.TIMESTAMP_WITH_LOCAL_TIME_ZONE), FACTORY.createSqlIntervalType(new SqlIntervalQualifier(TimeUnit.DAY, 2, TimeUnit.MINUTE, RelDataType.PRECISION_NOT_SPECIFIED, SqlParserPos.ZERO)), FACTORY.createSqlIntervalType(new SqlIntervalQualifier(TimeUnit.DAY, 6, TimeUnit.SECOND, 9, SqlParserPos.ZERO)), FACTORY.createSqlIntervalType(new SqlIntervalQualifier(TimeUnit.HOUR, RelDataType.PRECISION_NOT_SPECIFIED, TimeUnit.SECOND, 9, SqlParserPos.ZERO)), FACTORY.createSqlIntervalType(new SqlIntervalQualifier(TimeUnit.MINUTE, RelDataType.PRECISION_NOT_SPECIFIED, TimeUnit.SECOND, 0, SqlParserPos.ZERO)), FACTORY.createSqlIntervalType(new SqlIntervalQualifier(TimeUnit.SECOND, RelDataType.PRECISION_NOT_SPECIFIED, TimeUnit.SECOND, 6, SqlParserPos.ZERO)), FACTORY.createSqlType(SqlTypeName.CHAR), FACTORY.createSqlType(SqlTypeName.CHAR, 0), FACTORY.createSqlType(SqlTypeName.CHAR, 32), FACTORY.createSqlType(SqlTypeName.VARCHAR), FACTORY.createSqlType(SqlTypeName.VARCHAR, 0), FACTORY.createSqlType(SqlTypeName.VARCHAR, 10), FACTORY.createSqlType(SqlTypeName.BINARY), FACTORY.createSqlType(SqlTypeName.BINARY, 0), FACTORY.createSqlType(SqlTypeName.BINARY, 100), FACTORY.createSqlType(SqlTypeName.VARBINARY), FACTORY.createSqlType(SqlTypeName.VARBINARY, 0), FACTORY.createSqlType(SqlTypeName.VARBINARY, 1000), FACTORY.createSqlType(SqlTypeName.NULL), FACTORY.createSqlType(SqlTypeName.SYMBOL), FACTORY.createMultisetType(FACTORY.createSqlType(SqlTypeName.VARCHAR), -1), FACTORY.createArrayType(FACTORY.createSqlType(SqlTypeName.VARCHAR, 16), -1), FACTORY.createArrayType(FACTORY.createArrayType(FACTORY.createSqlType(SqlTypeName.VARCHAR, 16), -1), -1), FACTORY.createMapType(FACTORY.createSqlType(SqlTypeName.INTEGER), FACTORY.createSqlType(SqlTypeName.VARCHAR, 10)), FACTORY.createMapType(FACTORY.createMapType(FACTORY.createSqlType(SqlTypeName.INTEGER), FACTORY.createSqlType(SqlTypeName.VARCHAR, 10)), FACTORY.createArrayType(FACTORY.createMapType(FACTORY.createSqlType(SqlTypeName.INTEGER), FACTORY.createSqlType(SqlTypeName.VARCHAR, 10)), -1)), // simple struct type
FACTORY.createStructType(StructKind.PEEK_FIELDS_NO_EXPAND, Arrays.asList(FACTORY.createSqlType(SqlTypeName.INTEGER), FACTORY.createSqlType(SqlTypeName.DECIMAL, 10, 3)), Arrays.asList("f1", "f2")), // struct type with array type
FACTORY.createStructType(StructKind.PEEK_FIELDS_NO_EXPAND, Arrays.asList(FACTORY.createSqlType(SqlTypeName.VARCHAR), FACTORY.createArrayType(FACTORY.createSqlType(SqlTypeName.VARCHAR, 16), -1)), Arrays.asList("f1", "f2")), // nested struct type
FACTORY.createStructType(StructKind.PEEK_FIELDS_NO_EXPAND, Arrays.asList(FACTORY.createStructType(StructKind.PEEK_FIELDS_NO_EXPAND, Arrays.asList(FACTORY.createSqlType(SqlTypeName.VARCHAR, 5), FACTORY.createSqlType(SqlTypeName.VARCHAR, 10)), Arrays.asList("f1", "f2")), FACTORY.createArrayType(FACTORY.createSqlType(SqlTypeName.VARCHAR, 16), -1)), Arrays.asList("f3", "f4")), FACTORY.createRowtimeIndicatorType(true, false), FACTORY.createRowtimeIndicatorType(true, true), FACTORY.createProctimeIndicatorType(true), FACTORY.createFieldTypeFromLogicalType(StructuredType.newBuilder(ObjectIdentifier.of("cat", "db", "structuredType"), DataTypeJsonSerdeTest.PojoClass.class).attributes(Arrays.asList(new StructuredType.StructuredAttribute("f0", new IntType(true)), new StructuredType.StructuredAttribute("f1", new BigIntType(true)), new StructuredType.StructuredAttribute("f2", new VarCharType(200), "desc"))).comparison(StructuredType.StructuredComparison.FULL).setFinal(false).setInstantiable(false).description("description for StructuredType").build()));
final List<RelDataType> mutableTypes = new ArrayList<>(types.size() * 2);
for (RelDataType type : types) {
mutableTypes.add(FACTORY.createTypeWithNullability(type, true));
mutableTypes.add(FACTORY.createTypeWithNullability(type, false));
}
mutableTypes.add(FACTORY.createTypeWithNullability(FACTORY.createFieldTypeFromLogicalType(new RawType<>(true, Void.class, VoidSerializer.INSTANCE)), true));
mutableTypes.add(FACTORY.createTypeWithNullability(FACTORY.createFieldTypeFromLogicalType(new RawType<>(false, Void.class, VoidSerializer.INSTANCE)), false));
mutableTypes.add(FACTORY.createTypeWithNullability(FACTORY.createFieldTypeFromLogicalType(new RawType<>(true, Void.class, VoidSerializer.INSTANCE)), false));
return mutableTypes;
}
use of org.apache.flink.table.types.logical.VarCharType in project flink by apache.
the class EqualiserCodeGeneratorTest method testManyFields.
@Test
public void testManyFields() {
final LogicalType[] fieldTypes = IntStream.range(0, 499).mapToObj(i -> new VarCharType()).toArray(LogicalType[]::new);
final RecordEqualiser equaliser = new EqualiserCodeGenerator(fieldTypes).generateRecordEqualiser("ManyFields").newInstance(Thread.currentThread().getContextClassLoader());
final StringData[] fields = IntStream.range(0, 499).mapToObj(i -> StringData.fromString("Entry " + i)).toArray(StringData[]::new);
assertTrue(equaliser.equals(GenericRowData.of((Object[]) fields), GenericRowData.of((Object[]) fields)));
}
Aggregations