return (String) entry.getKey(); }, e -> getAvroValue(e, type.getMapValueType())));
public String getPrettyName() { if (isArray()) { return "ARRAY<" + getArrayElementType().toString() + ">"; } if (isMap()) { return "MAP<STRING, " + getMapValueType().toString() + ">"; } return toString(); } }
return getMap(type.getMapValueType(), jp.getValueAsString());
public static String toSql(FieldType type) { switch (type) { case LONG: return StandardTypes.BIGINT; case STRING: return StandardTypes.VARCHAR; case BINARY: return StandardTypes.VARBINARY; case DECIMAL: case INTEGER: case BOOLEAN: case DATE: case TIME: case DOUBLE: case TIMESTAMP: return type.name(); default: if (type.isArray()) { return "ARRAY<" + toSql(type.getArrayElementType()) + ">"; } if (type.isMap()) { return "MAP<VARCHAR, " + toSql(type.getMapValueType()) + ">"; } throw new IllegalStateException("sql type couldn't converted to fieldtype"); } }
Object value; if (t.isScalarValue()) { value = getValue(jp, type.getMapValueType(), null, false, project, collection); } else { value = JsonHelper.encode(jp.readValueAsTree()); if (type.getMapValueType() != STRING) { throw new JsonMappingException(jp, String.format("Nested properties are not supported if the type is not MAP_STRING. ('%s' field)", field.name())); value = getValue(jp, type.getMapValueType(), null, false, project, collection);
public static String toSql(FieldType type) { switch (type) { case INTEGER: return "INT"; case DECIMAL: return "DECIMAL"; case LONG: return "BIGINT"; case STRING: return "VARCHAR"; case BINARY: return "VARBINARY"; case BOOLEAN: case DATE: case TIME: case TIMESTAMP: return type.name(); case DOUBLE: return "DOUBLE"; default: if (type.isArray()) { return "ARRAY<" + toSql(type.getArrayElementType()) + ">"; } if (type.isMap()) { return "MAP<VARCHAR, " + toSql(type.getMapValueType()) + ">"; } throw new IllegalStateException("sql type couldn't converted to fieldtype"); } }
appendValue(builder, ((Map) value).keySet(), FieldType.ARRAY_STRING); builder.append(", "); appendValue(builder, ((Map) value).values(), type.getMapValueType().convertToArrayType()); builder.append(')');
TypeParameter.of(toType(type.getMapValueType()))));
default: if (type.isMap()) { Schema union = Schema.createUnion(ImmutableList.of(Schema.create(Schema.Type.NULL), getAvroSchema(type.getMapValueType()))); return Schema.createMap(union);
FieldType mapValueType = type.getMapValueType();
public static String toClickHouseType(FieldType type) { switch (type) { case INTEGER: case TIME: return "Int32"; case LONG: return "Int64"; case STRING: case BINARY: return "String"; case BOOLEAN: return "UInt8"; case DATE: return "Date"; case TIMESTAMP: return "DateTime"; case DECIMAL: case DOUBLE: return "Float64"; default: if (type.isArray()) { return "Array(" + toClickHouseType(type.getArrayElementType()) + ")"; } if (type.isMap()) { return "Nested(Key String, Value " + toClickHouseType(type.getMapValueType()) + ")"; } throw new IllegalStateException("sql type couldn't converted to fieldtype"); } }