@Override public Schema record(Schema record, List<String> names, Iterable<Schema.Field> schemaIterable) { Preconditions.checkArgument( current.isNestedType() && current.asNestedType().isStructType(), "Cannot project non-struct: %s", current);
public static Schema fromJson(JsonNode json) { Type type = typeFromJson(json); Preconditions.checkArgument(type.isNestedType() && type.asNestedType().isStructType(), "Cannot create schema, not a struct type: %s", type); return new Schema(type.asNestedType().asStructType().fields()); }
@Override public Schema map(Schema map, Supplier<Schema> value) { Preconditions.checkArgument(current.isNestedType() && current.asNestedType().isMapType(), "Incompatible projected type: %s", current); Types.MapType m = current.asNestedType().asMapType(); Preconditions.checkArgument(m.keyType() == Types.StringType.get(), "Incompatible projected type: key type %s is not string", m.keyType()); this.current = m.valueType(); try { Schema valueSchema = value.get(); // element was changed, create a new map if (valueSchema != map.getValueType()) { return Schema.createMap(valueSchema); } return map; } finally { this.current = m; } }
Preconditions.checkArgument(parentField != null, "Cannot find parent struct: %s", parent); Type parentType = parentField.type(); if (parentType.isNestedType()) { Type.NestedType nested = parentType.asNestedType(); if (nested.isMapType()) { parentField.type().isNestedType() && parentField.type().asNestedType().isStructType(), "Cannot add to non-struct column: %s: %s", parent, parentField.type()); parentId = parentField.fieldId();