/** * Convert value to a parquet type and perform null check. * @param value * @return Parquet safe type */ public Object convert(JsonElement value) { if (value.isJsonNull()) { if (this.jsonSchema.isNullable()) { return null; } throw new RuntimeException( "Field: " + this.jsonSchema.getColumnName() + " is not nullable and contains a null value"); } return convertField(value); }
@Override protected Type buildSchema() { List<Type> fields = new ArrayList<>(); fields.add(0, this.elementConverter.schema()); return new GroupType(this.jsonSchema.optionalOrRequired(), this.jsonSchema.getColumnName(), fields); }
@Override JsonSchema getElementSchema() { JsonSchema jsonSchema = JsonSchema.buildBaseSchema(STRING); jsonSchema.setColumnName(this.jsonSchema.getColumnName()); return jsonSchema; } }
protected Type buildSchema() { return new PrimitiveType(this.repeated ? REPEATED : this.jsonSchema.optionalOrRequired(), this.outputType, this.jsonSchema.getColumnName()); }
private Type buildSchema() { JsonArray inputSchema = this.jsonSchema.getDataTypeValues(); List<Type> parquetTypes = new ArrayList<>(); for (JsonElement element : inputSchema) { JsonObject map = (JsonObject) element; JsonSchema elementSchema = new JsonSchema(map); String columnName = elementSchema.getColumnName(); JsonElementConverter converter = JsonElementConversionFactory.getConverter(elementSchema, false); Type schemaType = converter.schema(); this.converters.put(columnName, converter); parquetTypes.add(schemaType); } String docName = this.jsonSchema.getColumnName(); switch (recordType) { case ROOT: return new MessageType(docName, parquetTypes); case CHILD: return new GroupType(this.jsonSchema.optionalOrRequired(), docName, parquetTypes); default: throw new RuntimeException("Unsupported Record type"); } }
@Override protected Type buildSchema() { String columnName = this.jsonSchema.getColumnName(); if (this.repeated) { return Types.repeated(BINARY).as(UTF8).named(columnName); } switch (this.jsonSchema.optionalOrRequired()) { case OPTIONAL: return Types.optional(BINARY).as(UTF8).named(columnName); case REQUIRED: return Types.required(BINARY).as(UTF8).named(columnName); default: throw new RuntimeException("Unsupported Repetition type"); } } }
@Override protected Type buildSchema() { JsonElementConverter elementConverter = this.elementConverter; JsonElementConverter keyConverter = getKeyConverter(); GroupType mapGroup = Types.repeatedGroup().addFields(keyConverter.schema(), elementConverter.schema()).named(MAP_KEY) .asGroupType(); String columnName = this.jsonSchema.getColumnName(); switch (this.jsonSchema.optionalOrRequired()) { case OPTIONAL: return Types.optionalGroup().addFields(mapGroup).named(columnName).asGroupType(); case REQUIRED: return Types.requiredGroup().addFields(mapGroup).named(columnName).asGroupType(); default: return null; } }
/** * Convert value to a parquet type and perform null check. * @param value * @return Parquet safe type */ public Object convert(JsonElement value) { if (value.isJsonNull()) { if (this.jsonSchema.isNullable()) { return null; } throw new RuntimeException( "Field: " + this.jsonSchema.getColumnName() + " is not nullable and contains a null value"); } return convertField(value); }
@Override protected Type buildSchema() { List<Type> fields = new ArrayList<>(); fields.add(0, this.elementConverter.schema()); return new GroupType(this.jsonSchema.optionalOrRequired(), this.jsonSchema.getColumnName(), fields); }
@Override JsonSchema getElementSchema() { JsonSchema jsonSchema = JsonSchema.buildBaseSchema(STRING); jsonSchema.setColumnName(this.jsonSchema.getColumnName()); return jsonSchema; } }
protected Type buildSchema() { return new PrimitiveType(this.repeated ? REPEATED : this.jsonSchema.optionalOrRequired(), this.outputType, this.jsonSchema.getColumnName()); }
private Type buildSchema() { JsonArray inputSchema = this.jsonSchema.getDataTypeValues(); List<Type> parquetTypes = new ArrayList<>(); for (JsonElement element : inputSchema) { JsonObject map = (JsonObject) element; JsonSchema elementSchema = new JsonSchema(map); String columnName = elementSchema.getColumnName(); JsonElementConverter converter = JsonElementConversionFactory.getConverter(elementSchema, false); Type schemaType = converter.schema(); this.converters.put(columnName, converter); parquetTypes.add(schemaType); } String docName = this.jsonSchema.getColumnName(); switch (recordType) { case ROOT: return new MessageType(docName, parquetTypes); case CHILD: return new GroupType(this.jsonSchema.optionalOrRequired(), docName, parquetTypes); default: throw new RuntimeException("Unsupported Record type"); } }
@Override protected Type buildSchema() { String columnName = this.jsonSchema.getColumnName(); if (this.repeated) { return Types.repeated(BINARY).as(UTF8).named(columnName); } switch (this.jsonSchema.optionalOrRequired()) { case OPTIONAL: return Types.optional(BINARY).as(UTF8).named(columnName); case REQUIRED: return Types.required(BINARY).as(UTF8).named(columnName); default: throw new RuntimeException("Unsupported Repetition type"); } } }
@Override protected Type buildSchema() { JsonElementConverter elementConverter = this.elementConverter; JsonElementConverter keyConverter = getKeyConverter(); GroupType mapGroup = Types.repeatedGroup().addFields(keyConverter.schema(), elementConverter.schema()).named(MAP_KEY) .asGroupType(); String columnName = this.jsonSchema.getColumnName(); switch (this.jsonSchema.optionalOrRequired()) { case OPTIONAL: return Types.optionalGroup().addFields(mapGroup).named(columnName).asGroupType(); case REQUIRED: return Types.requiredGroup().addFields(mapGroup).named(columnName).asGroupType(); default: return null; } }