Skip to content

Commit

Permalink
Support map of complex types (#1764)
Browse files Browse the repository at this point in the history
  • Loading branch information
ejeffrli authored Feb 19, 2024
1 parent b56f062 commit 91cf7fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class GlueFieldLexer

private static final BaseTypeMapper DEFAULT_TYPE_MAPPER = (String type) -> DefaultGlueType.toArrowType(type);

public static final boolean MAP_DISABLED = true;
public static final boolean MAP_DISABLED = false;

private GlueFieldLexer() {}

Expand Down Expand Up @@ -160,11 +160,11 @@ private static Field parseMap(String name, GlueTypeParser.Token typeToken, GlueT

FieldType keyFieldTypeNotNullable = new FieldType(false, keyType.getType(), keyType.getDictionary(), keyType.getMetadata());
Field keyFieldNotNullable = new Field(keyType.getName(), keyFieldTypeNotNullable, keyType.getChildren());

return FieldBuilder.newBuilder(name, new ArrowType.Map(false))
.addField("ENTRIES", Types.MinorType.STRUCT.getType(), false,
Arrays.asList(keyFieldNotNullable, valueType))
.build();
.addField("entries", Types.MinorType.STRUCT.getType(), false,
Arrays.asList(keyFieldNotNullable, valueType))
.build();
}

private static void expectTokenMarkerIsFieldStart(GlueTypeParser.Token token)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ public void lexMapTest()
// complex case
String input = "map<array<int>, map<string, string>>";
Field field = GlueFieldLexer.lex("SomeMap", input);
String expectedFieldToString = "SomeMap: Map(false)<ENTRIES: Struct<key: List<key: Int(32, true)> not null, value: Map(false)<ENTRIES: Struct<key: Utf8 not null, value: Utf8> not null>> not null>";
String expectedFieldToString = "SomeMap: Map(false)<entries: Struct<key: List<key: Int(32, true)> not null, value: Map(false)<entries: Struct<key: Utf8 not null, value: Utf8> not null>> not null>";
assertEquals(expectedFieldToString, field.toString());

// Extra complex case
Expand All @@ -344,7 +344,7 @@ public void lexMapTest()
">";
String input2 = "map<" + innerStruct + ", map<string, " + innerStruct + ">>";
Field field2 = GlueFieldLexer.lex("SomeMap2", input2);
String expectedFieldToString2 = "SomeMap2: Map(false)<ENTRIES: Struct<key: Struct<somearrfield0: List<somearrfield0: List<somearrfield0: Struct<somefield: Decimal(38, 9, 128), someset: List<someset: Decimal(11, 7, 128)>>>>, mapinner0: Struct<numberset_deep: List<numberset_deep: Decimal(23, 3, 8)>>> not null, value: Map(false)<ENTRIES: Struct<key: Utf8 not null, value: Struct<somearrfield0: List<somearrfield0: List<somearrfield0: Struct<somefield: Decimal(38, 9, 128), someset: List<someset: Decimal(11, 7, 128)>>>>, mapinner0: Struct<numberset_deep: List<numberset_deep: Decimal(23, 3, 8)>>>> not null>> not null>";
String expectedFieldToString2 = "SomeMap2: Map(false)<entries: Struct<key: Struct<somearrfield0: List<somearrfield0: List<somearrfield0: Struct<somefield: Decimal(38, 9, 128), someset: List<someset: Decimal(11, 7, 128)>>>>, mapinner0: Struct<numberset_deep: List<numberset_deep: Decimal(23, 3, 8)>>> not null, value: Map(false)<entries: Struct<key: Utf8 not null, value: Struct<somearrfield0: List<somearrfield0: List<somearrfield0: Struct<somefield: Decimal(38, 9, 128), someset: List<someset: Decimal(11, 7, 128)>>>>, mapinner0: Struct<numberset_deep: List<numberset_deep: Decimal(23, 3, 8)>>>> not null>> not null>";
assertEquals(expectedFieldToString2, field2.toString());
}
}
Expand Down

0 comments on commit 91cf7fb

Please sign in to comment.