Search in sources :

Example 16 with MapType

use of org.apache.flink.table.types.logical.MapType in project flink by apache.

the class LogicalTypeJsonDeserializer method deserializeMap.

private static LogicalType deserializeMap(JsonNode logicalTypeNode, SerdeContext serdeContext) {
    final JsonNode keyNode = logicalTypeNode.get(FIELD_NAME_KEY_TYPE);
    final LogicalType keyType = deserialize(keyNode, serdeContext);
    final JsonNode valueNode = logicalTypeNode.get(FIELD_NAME_VALUE_TYPE);
    final LogicalType valueType = deserialize(valueNode, serdeContext);
    return new MapType(keyType, valueType);
}
Also used : LogicalType(org.apache.flink.table.types.logical.LogicalType) JsonNode(org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode) MapType(org.apache.flink.table.types.logical.MapType)

Example 17 with MapType

use of org.apache.flink.table.types.logical.MapType in project flink by apache.

the class RowDataSerializerTest method testRowDataSerializerWithComplexTypes.

private static Object[] testRowDataSerializerWithComplexTypes() {
    InternalTypeInfo<RowData> typeInfo = InternalTypeInfo.ofFields(new IntType(), new DoubleType(), VarCharType.STRING_TYPE, new ArrayType(new IntType()), new MapType(new IntType(), new IntType()));
    GenericRowData[] data = new GenericRowData[] { createRow(null, null, null, null, null), createRow(0, null, null, null, null), createRow(0, 0.0, null, null, null), createRow(0, 0.0, fromString("a"), null, null), createRow(1, 0.0, fromString("a"), null, null), createRow(1, 1.0, fromString("a"), null, null), createRow(1, 1.0, fromString("b"), null, null), createRow(1, 1.0, fromString("b"), createArray(1), createMap(new int[] { 1 }, new int[] { 1 })), createRow(1, 1.0, fromString("b"), createArray(1, 2), createMap(new int[] { 1, 4 }, new int[] { 1, 2 })), createRow(1, 1.0, fromString("b"), createArray(1, 2, 3), createMap(new int[] { 1, 5 }, new int[] { 1, 3 })), createRow(1, 1.0, fromString("b"), createArray(1, 2, 3, 4), createMap(new int[] { 1, 6 }, new int[] { 1, 4 })), createRow(1, 1.0, fromString("b"), createArray(1, 2, 3, 4, 5), createMap(new int[] { 1, 7 }, new int[] { 1, 5 })), createRow(1, 1.0, fromString("b"), createArray(1, 2, 3, 4, 5, 6), createMap(new int[] { 1, 8 }, new int[] { 1, 6 })) };
    RowDataSerializer serializer = typeInfo.toRowSerializer();
    return new Object[] { serializer, data };
}
Also used : ArrayType(org.apache.flink.table.types.logical.ArrayType) GenericRowData(org.apache.flink.table.data.GenericRowData) RowData(org.apache.flink.table.data.RowData) BinaryRowData(org.apache.flink.table.data.binary.BinaryRowData) DoubleType(org.apache.flink.table.types.logical.DoubleType) GenericRowData(org.apache.flink.table.data.GenericRowData) MapType(org.apache.flink.table.types.logical.MapType) IntType(org.apache.flink.table.types.logical.IntType)

Aggregations

MapType (org.apache.flink.table.types.logical.MapType)17 ArrayType (org.apache.flink.table.types.logical.ArrayType)9 LogicalType (org.apache.flink.table.types.logical.LogicalType)8 IntType (org.apache.flink.table.types.logical.IntType)7 RowType (org.apache.flink.table.types.logical.RowType)7 TimestampType (org.apache.flink.table.types.logical.TimestampType)5 VarCharType (org.apache.flink.table.types.logical.VarCharType)5 Map (java.util.Map)4 GenericRowData (org.apache.flink.table.data.GenericRowData)4 DataType (org.apache.flink.table.types.DataType)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 List (java.util.List)3 RowData (org.apache.flink.table.data.RowData)3 KeyValueDataType (org.apache.flink.table.types.KeyValueDataType)3 DecimalType (org.apache.flink.table.types.logical.DecimalType)3 MultisetType (org.apache.flink.table.types.logical.MultisetType)3 LocalDateTime (java.time.LocalDateTime)2 Internal (org.apache.flink.annotation.Internal)2 JsonNode (org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode)2