Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,12 @@ else if (typeInfo.getCategory() == Category.UNION) {
private static GroupType convertArrayType(String name, ListTypeInfo typeInfo)
{
TypeInfo subType = typeInfo.getListElementTypeInfo();
return listWrapper(name, LogicalTypeAnnotation.listType(), new GroupType(Repetition.REPEATED,
ParquetHiveSerDe.ARRAY.toString(), convertType("array_element", subType)));
return listWrapper(
name,
new GroupType(
Repetition.REPEATED,
ParquetHiveSerDe.ARRAY.toString(),
convertType("array_element", subType)));
}

// An optional group containing multiple elements
Expand All @@ -171,10 +175,9 @@ public static GroupType mapType(Repetition repetition, String alias, String mapA
{
//support projection only on key of a map
if (valueType == null) {
return listWrapper(
return mapKvWrapper(
Comment thread
nevillelyh marked this conversation as resolved.
repetition,
alias,
LogicalTypeAnnotation.MapKeyValueTypeAnnotation.getInstance(),
new GroupType(
Repetition.REPEATED,
mapAlias,
Expand All @@ -184,10 +187,9 @@ public static GroupType mapType(Repetition repetition, String alias, String mapA
if (!valueType.getName().equals("value")) {
throw new RuntimeException(valueType.getName() + " should be value");
}
return listWrapper(
return mapKvWrapper(
repetition,
alias,
LogicalTypeAnnotation.MapKeyValueTypeAnnotation.getInstance(),
new GroupType(
Repetition.REPEATED,
mapAlias,
Expand All @@ -196,16 +198,16 @@ public static GroupType mapType(Repetition repetition, String alias, String mapA
}
}

private static GroupType listWrapper(Repetition repetition, String alias, LogicalTypeAnnotation logicalType, Type nested)
private static GroupType mapKvWrapper(Repetition repetition, String alias, Type nested)
{
if (!nested.isRepetition(Repetition.REPEATED)) {
throw new IllegalArgumentException("Nested type should be repeated: " + nested);
}
return Types.buildGroup(repetition).as(logicalType).addField(nested).named(alias);
return Types.buildGroup(repetition).as(LogicalTypeAnnotation.MapKeyValueTypeAnnotation.getInstance()).addField(nested).named(alias);
}

private static GroupType listWrapper(String name, LogicalTypeAnnotation logicalType, GroupType groupType)
private static GroupType listWrapper(String name, GroupType groupType)
{
return Types.optionalGroup().as(logicalType).addField(groupType).named(name);
return Types.optionalGroup().as(LogicalTypeAnnotation.listType()).addField(groupType).named(name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ private static Type convertType(String name, TypeInfo typeInfo, Repetition repet
private static GroupType convertArrayType(String name, ListTypeInfo typeInfo, Repetition repetition)
{
TypeInfo subType = typeInfo.getListElementTypeInfo();
return listWrapper(name, LogicalTypeAnnotation.listType(), convertType("array_element", subType, Repetition.REPEATED), repetition);
return listWrapper(name, convertType("array_element", subType, Repetition.REPEATED), repetition);
}

// An optional group containing multiple elements
Expand All @@ -175,10 +175,9 @@ public static GroupType mapType(Repetition repetition, String alias, String mapA
{
//support projection only on key of a map
if (valueType == null) {
return listWrapper(
return mapKvWrapper(
repetition,
alias,
LogicalTypeAnnotation.MapKeyValueTypeAnnotation.getInstance(),
new GroupType(
Repetition.REPEATED,
mapAlias,
Expand All @@ -187,27 +186,26 @@ public static GroupType mapType(Repetition repetition, String alias, String mapA
if (!valueType.getName().equals("value")) {
throw new RuntimeException(valueType.getName() + " should be value");
}
return listWrapper(
return mapKvWrapper(
repetition,
alias,
LogicalTypeAnnotation.MapKeyValueTypeAnnotation.getInstance(),
new GroupType(
Repetition.REPEATED,
mapAlias,
keyType,
valueType));
}

private static GroupType listWrapper(Repetition repetition, String alias, LogicalTypeAnnotation logicalType, Type nested)
private static GroupType mapKvWrapper(Repetition repetition, String alias, Type nested)
{
if (!nested.isRepetition(Repetition.REPEATED)) {
throw new IllegalArgumentException("Nested type should be repeated: " + nested);
}
return Types.buildGroup(repetition).as(logicalType).addField(nested).named(alias);
return Types.buildGroup(repetition).as(LogicalTypeAnnotation.MapKeyValueTypeAnnotation.getInstance()).addField(nested).named(alias);
}

private static GroupType listWrapper(String name, LogicalTypeAnnotation logicalType, Type elementType, Repetition repetition)
private static GroupType listWrapper(String name, Type elementType, Repetition repetition)
{
return Types.buildGroup(repetition).as(logicalType).addField(elementType).named(name);
return Types.buildGroup(repetition).as(LogicalTypeAnnotation.listType()).addField(elementType).named(name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ else if (typeInfo.getCategory() == Category.UNION) {
private static GroupType convertArrayType(String name, ListTypeInfo typeInfo, Repetition repetition)
{
TypeInfo subType = typeInfo.getListElementTypeInfo();
return listWrapper(name, LogicalTypeAnnotation.listType(), convertType("array", subType, Repetition.REPEATED), repetition);
return listWrapper(name, convertType("array", subType, Repetition.REPEATED), repetition);
}

// An optional group containing multiple elements
Expand All @@ -183,9 +183,8 @@ private static GroupType convertMapType(String name, MapTypeInfo typeInfo, Repet
return ConversionPatterns.mapType(repetition, name, keyType, valueType);
}

private static GroupType listWrapper(String name, LogicalTypeAnnotation logicalType,
Type elementType, Repetition repetition)
private static GroupType listWrapper(String name, Type elementType, Repetition repetition)
{
return Types.buildGroup(repetition).as(logicalType).addField(elementType).named(name);
return Types.buildGroup(repetition).as(LogicalTypeAnnotation.listType()).addField(elementType).named(name);
}
}