use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.dataformat.csv.CsvSchema.Builder in project flink by apache.
the class RexNodeJsonDeserializer method deserializeSarg.
@SuppressWarnings({ "UnstableApiUsage", "rawtypes", "unchecked" })
private static RexNode deserializeSarg(JsonNode sargNode, RelDataType relDataType, SerdeContext serdeContext) {
final RexBuilder rexBuilder = serdeContext.getRexBuilder();
final ArrayNode rangesNode = (ArrayNode) sargNode.required(FIELD_NAME_RANGES);
final Builder builder = builder();
for (JsonNode rangeNode : rangesNode) {
Range range = all();
if (rangeNode.has(FIELD_NAME_BOUND_LOWER)) {
final JsonNode lowerNode = rangeNode.required(FIELD_NAME_BOUND_LOWER);
final Comparable<?> boundValue = (Comparable<?>) deserializeLiteralValue(lowerNode, relDataType.getSqlTypeName(), serdeContext);
assert boundValue != null;
final BoundType boundType = serializableToCalcite(BoundType.class, lowerNode.required(FIELD_NAME_BOUND_TYPE).asText());
final Range<?> r = boundType == BoundType.OPEN ? greaterThan(boundValue) : atLeast(boundValue);
range = range.intersection(r);
}
if (rangeNode.has(FIELD_NAME_BOUND_UPPER)) {
final JsonNode upperNode = rangeNode.required(FIELD_NAME_BOUND_UPPER);
final Comparable<?> boundValue = (Comparable<?>) deserializeLiteralValue(upperNode, relDataType.getSqlTypeName(), serdeContext);
assert boundValue != null;
final BoundType boundType = serializableToCalcite(BoundType.class, upperNode.required(FIELD_NAME_BOUND_TYPE).asText());
final Range<?> r = boundType == BoundType.OPEN ? lessThan(boundValue) : atMost(boundValue);
range = range.intersection(r);
}
if (range.hasUpperBound() || range.hasLowerBound()) {
builder.add(range);
}
}
final boolean containsNull = sargNode.required(FIELD_NAME_CONTAINS_NULL).booleanValue();
return rexBuilder.makeSearchArgumentLiteral(Sarg.of(containsNull, builder.build()), relDataType);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.dataformat.csv.CsvSchema.Builder in project flink by apache.
the class LogicalTypeJsonDeserializer method deserializeStructuredTypeFromPlan.
private static LogicalType deserializeStructuredTypeFromPlan(JsonNode logicalTypeNode, SerdeContext serdeContext) {
final ObjectIdentifier identifier;
if (logicalTypeNode.has(FIELD_NAME_OBJECT_IDENTIFIER)) {
identifier = ObjectIdentifierJsonDeserializer.deserialize(logicalTypeNode.get(FIELD_NAME_OBJECT_IDENTIFIER).asText(), serdeContext);
} else {
identifier = null;
}
final Class<?> implementationClass;
if (logicalTypeNode.has(FIELD_NAME_IMPLEMENTATION_CLASS)) {
implementationClass = loadClass(logicalTypeNode.get(FIELD_NAME_IMPLEMENTATION_CLASS).asText(), serdeContext, "structured type");
} else {
implementationClass = null;
}
final StructuredType.Builder builder;
if (identifier != null && implementationClass != null) {
builder = StructuredType.newBuilder(identifier, implementationClass);
} else if (identifier != null) {
builder = StructuredType.newBuilder(identifier);
} else {
builder = StructuredType.newBuilder(implementationClass);
}
if (logicalTypeNode.has(FIELD_NAME_DESCRIPTION)) {
builder.description(logicalTypeNode.get(FIELD_NAME_FIELD_DESCRIPTION).asText());
}
final ArrayNode attributeNodes = (ArrayNode) logicalTypeNode.get(FIELD_NAME_ATTRIBUTES);
final List<StructuredAttribute> attributes = new ArrayList<>();
for (JsonNode attributeNode : attributeNodes) {
final String attributeName = attributeNode.get(FIELD_NAME_ATTRIBUTE_NAME).asText();
final LogicalType attributeType = deserialize(attributeNode.get(FIELD_NAME_ATTRIBUTE_TYPE), serdeContext);
final String attributeDescription;
if (attributeNode.has(FIELD_NAME_ATTRIBUTE_DESCRIPTION)) {
attributeDescription = attributeNode.get(FIELD_NAME_ATTRIBUTE_DESCRIPTION).asText();
} else {
attributeDescription = null;
}
attributes.add(new StructuredAttribute(attributeName, attributeType, attributeDescription));
}
builder.attributes(attributes);
if (logicalTypeNode.has(FIELD_NAME_FINAL)) {
builder.setFinal(logicalTypeNode.get(FIELD_NAME_FINAL).asBoolean());
}
if (logicalTypeNode.has(FIELD_NAME_INSTANTIABLE)) {
builder.setInstantiable(logicalTypeNode.get(FIELD_NAME_INSTANTIABLE).asBoolean());
}
if (logicalTypeNode.has(FIELD_NAME_COMPARISON)) {
builder.comparison(StructuredComparison.valueOf(logicalTypeNode.get(FIELD_NAME_COMPARISON).asText()));
}
if (logicalTypeNode.has(FIELD_NAME_SUPER_TYPE)) {
final StructuredType superType = (StructuredType) deserialize(logicalTypeNode.get(FIELD_NAME_SUPER_TYPE), serdeContext);
builder.superType(superType);
}
return builder.build();
}
Aggregations