@Override public Type array(ArrayType array, Type elementType) { if (array.containsNull()) { return Types.ListType.ofOptional(getNextId(), elementType); } else { return Types.ListType.ofRequired(getNextId(), elementType); } }
@Override public Type list(Types.ListType list, Supplier<Type> elementResult) { Preconditions.checkArgument(current instanceof ArrayType, "Not an array: %s", current); ArrayType array = (ArrayType) current; Preconditions.checkArgument(array.containsNull() || !list.isElementOptional(), "Cannot project an array of optional elements as required elements: %s", array); this.current = array.elementType(); try { Type elementType = elementResult.get(); if (list.elementType() == elementType) { return list; } // must be a projected element type, create a new list if (list.isElementOptional()) { return Types.ListType.ofOptional(list.elementId(), elementType); } else { return Types.ListType.ofRequired(list.elementId(), elementType); } } finally { this.current = array; } }
if (elementValue == null && !arrayType.containsNull()) { throw new IllegalArgumentException("Null value is not allowed for array element at " + elementPath);
if (elementValue == null && !arrayType.containsNull()) { throw new IllegalArgumentException("Null value is not allowed for array element at " + elementPath);
if (elementValue == null && !arrayType.containsNull()) { throw new IllegalArgumentException("Null value is not allowed for array element at " + elementPath);
@Override public Type list(Types.ListType list, Supplier<Type> elementResult) { Preconditions.checkArgument(current instanceof ArrayType, "Not an array: %s", current); ArrayType array = (ArrayType) current; Preconditions.checkArgument(array.containsNull() || !list.isElementOptional(), "Cannot project an array of optional elements as required elements: %s", array); this.current = array.elementType(); try { Type elementType = elementResult.get(); if (list.elementType() == elementType) { return list; } // must be a projected element type, create a new list if (list.isElementOptional()) { return Types.ListType.ofOptional(list.elementId(), elementType); } else { return Types.ListType.ofRequired(list.elementId(), elementType); } } finally { this.current = array; } }
type, elementType, value)); } else if (!((ArrayType) type).containsNull()) { throw new RuntimeException(String.format("Type[%s] - Element cannot be 'null': %s[null]", type, elementType)); type, elementType, value)); } else if (!((ArrayType) type).containsNull()) { throw new RuntimeException(String.format("Type[%s] - Value cannot be 'null': %s[null]", type, elementType));
return Schema.arrayOf(arrayType.containsNull() ? Schema.nullableOf(componentSchema) : componentSchema);
return Schema.arrayOf(arrayType.containsNull() ? Schema.nullableOf(componentSchema) : componentSchema);
return Schema.arrayOf(arrayType.containsNull() ? Schema.nullableOf(componentSchema) : componentSchema);
case "array": ArrayType arrayType = (ArrayType) dataType; typeSchema = typeBuilder.array().items(typeFor(arrayType.elementType(), arrayType.containsNull(), recordCount)); break; case "map":