public ParquetMapEntryConverter(Type prestoType, String columnName, GroupType entryType) { checkArgument(StandardTypes.MAP.equals(prestoType.getTypeSignature().getBase())); // original version of parquet used null for entry due to a bug if (entryType.getOriginalType() != null) { checkArgument( entryType.getOriginalType() == MAP_KEY_VALUE, "Expected MAP column '%s' field to be type %s, but is %s", columnName, MAP_KEY_VALUE, entryType); } GroupType entryGroupType = entryType.asGroupType(); checkArgument( entryGroupType.getFieldCount() == 2, "Expected MAP column '%s' entry to have two fields, but has %s fields", columnName, entryGroupType.getFieldCount()); checkArgument( entryGroupType.getFieldName(0).equals("key"), "Expected MAP column '%s' entry field 0 to be named 'key', but is named %s", columnName, entryGroupType.getFieldName(0)); checkArgument( entryGroupType.getFieldName(1).equals("value"), "Expected MAP column '%s' entry field 1 to be named 'value', but is named %s", columnName, entryGroupType.getFieldName(1)); checkArgument( entryGroupType.getType(0).isPrimitive(), "Expected MAP column '%s' entry field 0 to be primitive, but is named %s", columnName, entryGroupType.getType(0)); keyConverter = createConverter( prestoType.getTypeParameters().get(0), columnName + ".key", entryGroupType.getFields().get(0)); valueConverter = createConverter( prestoType.getTypeParameters().get(1), columnName + ".value", entryGroupType.getFields().get(1)); }
public ParquetMapConverter(Type type, String columnName, GroupType mapType) { checkArgument( mapType.getFieldCount() == 1, "Expected MAP column '%s' to only have one field, but has %s fields", mapType.getName(), mapType.getFieldCount()); this.mapType = type; parquet.schema.Type entryType = mapType.getFields().get(0); entryConverter = new ParquetMapEntryConverter(type, columnName + ".entry", entryType.asGroupType()); }
public ParquetStructConverter(Type prestoType, String columnName, GroupType entryType) { checkArgument(ROW.equals(prestoType.getTypeSignature().getBase())); List<Type> prestoTypeParameters = prestoType.getTypeParameters(); List<parquet.schema.Type> fieldTypes = entryType.getFields(); checkArgument(prestoTypeParameters.size() == fieldTypes.size()); this.rowType = prestoType; ImmutableList.Builder<BlockConverter> converters = ImmutableList.builder(); for (int i = 0; i < prestoTypeParameters.size(); i++) { parquet.schema.Type fieldType = fieldTypes.get(i); converters.add( createConverter( prestoTypeParameters.get(i), columnName + "." + fieldType.getName(), fieldType)); } this.converters = converters.build(); }