Search in sources :

Example 1 with ExternalSerializer

use of org.apache.flink.table.runtime.typeutils.ExternalSerializer in project flink by apache.

the class LogicalTypeJsonSerializer method serializeSpecializedRaw.

private static void serializeSpecializedRaw(RawType<?> rawType, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
    jsonGenerator.writeStringField(FIELD_NAME_CLASS, rawType.getOriginatingClass().getName());
    final TypeSerializer<?> serializer = rawType.getTypeSerializer();
    if (serializer.equals(NullSerializer.INSTANCE)) {
        jsonGenerator.writeStringField(FIELD_NAME_SPECIAL_SERIALIZER, FIELD_VALUE_EXTERNAL_SERIALIZER_NULL);
    } else if (serializer instanceof ExternalSerializer) {
        final ExternalSerializer<?, ?> externalSerializer = (ExternalSerializer<?, ?>) rawType.getTypeSerializer();
        if (externalSerializer.isInternalInput()) {
            throw new TableException("Asymmetric external serializers are currently not supported. " + "The input must not be internal if the output is external.");
        }
        serializerProvider.defaultSerializeField(FIELD_NAME_EXTERNAL_DATA_TYPE, externalSerializer.getDataType(), jsonGenerator);
    } else {
        throw new TableException("Unsupported special case for RAW type.");
    }
}
Also used : TableException(org.apache.flink.table.api.TableException) ExternalSerializer(org.apache.flink.table.runtime.typeutils.ExternalSerializer)

Aggregations

TableException (org.apache.flink.table.api.TableException)1 ExternalSerializer (org.apache.flink.table.runtime.typeutils.ExternalSerializer)1