Copilot commented on code in PR #11429:
URL: https://github.com/apache/gravitino/pull/11429#discussion_r3356109674
##########
catalogs/catalog-glue/src/test/java/org/apache/gravitino/catalog/glue/TestGlueIcebergTableHelper.java:
##########
@@ -130,6 +133,67 @@ void testFromIcebergTypeStruct() {
assertEquals(false, structType.fields()[1].nullable());
}
+ // -------------------------------------------------------------------------
+ // toIcebergSchema — complex types
+ // -------------------------------------------------------------------------
+
+ @Test
+ void testToIcebergSchemaWithListType() {
+ Column col =
+ GlueColumn.builder()
+ .withName("col_list")
+ .withType(Types.ListType.nullable(Types.StringType.get()))
+ .build();
+ Schema schema = GlueIcebergTableHelper.toIcebergSchema(new Column[] {col});
+
+ org.apache.iceberg.types.Types.NestedField field =
schema.findField("col_list");
+ assertInstanceOf(org.apache.iceberg.types.Types.ListType.class,
field.type());
+ org.apache.iceberg.types.Types.ListType listType =
+ (org.apache.iceberg.types.Types.ListType) field.type();
+ assertEquals(StringType.get(), listType.elementType());
+ assertTrue(listType.isElementOptional());
+ }
+
+ @Test
+ void testToIcebergSchemaWithMapType() {
+ Column col =
+ GlueColumn.builder()
+ .withName("col_map")
+ .withType(Types.MapType.of(Types.StringType.get(),
Types.LongType.get(), false))
+ .build();
+ Schema schema = GlueIcebergTableHelper.toIcebergSchema(new Column[] {col});
+
+ org.apache.iceberg.types.Types.NestedField field =
schema.findField("col_map");
+ assertInstanceOf(org.apache.iceberg.types.Types.MapType.class,
field.type());
+ org.apache.iceberg.types.Types.MapType mapType =
+ (org.apache.iceberg.types.Types.MapType) field.type();
Review Comment:
Avoid fully qualified Iceberg type names in the test body;
`NestedField`/`MapType` are already imported and there is no name collision
here.
##########
catalogs/catalog-glue/src/test/java/org/apache/gravitino/catalog/glue/TestGlueIcebergTableHelper.java:
##########
@@ -130,6 +133,67 @@ void testFromIcebergTypeStruct() {
assertEquals(false, structType.fields()[1].nullable());
}
+ // -------------------------------------------------------------------------
+ // toIcebergSchema — complex types
+ // -------------------------------------------------------------------------
+
+ @Test
+ void testToIcebergSchemaWithListType() {
+ Column col =
+ GlueColumn.builder()
+ .withName("col_list")
+ .withType(Types.ListType.nullable(Types.StringType.get()))
+ .build();
+ Schema schema = GlueIcebergTableHelper.toIcebergSchema(new Column[] {col});
+
+ org.apache.iceberg.types.Types.NestedField field =
schema.findField("col_list");
+ assertInstanceOf(org.apache.iceberg.types.Types.ListType.class,
field.type());
+ org.apache.iceberg.types.Types.ListType listType =
+ (org.apache.iceberg.types.Types.ListType) field.type();
+ assertEquals(StringType.get(), listType.elementType());
+ assertTrue(listType.isElementOptional());
+ }
+
+ @Test
+ void testToIcebergSchemaWithMapType() {
+ Column col =
+ GlueColumn.builder()
+ .withName("col_map")
+ .withType(Types.MapType.of(Types.StringType.get(),
Types.LongType.get(), false))
+ .build();
+ Schema schema = GlueIcebergTableHelper.toIcebergSchema(new Column[] {col});
+
+ org.apache.iceberg.types.Types.NestedField field =
schema.findField("col_map");
+ assertInstanceOf(org.apache.iceberg.types.Types.MapType.class,
field.type());
+ org.apache.iceberg.types.Types.MapType mapType =
+ (org.apache.iceberg.types.Types.MapType) field.type();
+ assertEquals(StringType.get(), mapType.keyType());
+ assertEquals(LongType.get(), mapType.valueType());
+ assertFalse(mapType.isValueOptional());
+ }
+
+ @Test
+ void testToIcebergSchemaWithStructType() {
+ Types.StructType gravitinoStruct =
+ Types.StructType.of(
+ Types.StructType.Field.of("name", Types.StringType.get(), true,
"the name"),
+ Types.StructType.Field.of("age", Types.IntegerType.get(), false,
null));
+ Column col =
GlueColumn.builder().withName("col_struct").withType(gravitinoStruct).build();
+ Schema schema = GlueIcebergTableHelper.toIcebergSchema(new Column[] {col});
+
+ org.apache.iceberg.types.Types.NestedField field =
schema.findField("col_struct");
+ assertInstanceOf(org.apache.iceberg.types.Types.StructType.class,
field.type());
+ org.apache.iceberg.types.Types.StructType structType =
+ (org.apache.iceberg.types.Types.StructType) field.type();
Review Comment:
Avoid fully qualified Iceberg type names in the test body;
`NestedField`/`StructType` are already imported and there is no name collision
here.
##########
catalogs/catalog-glue/src/test/java/org/apache/gravitino/catalog/glue/TestGlueIcebergTableHelper.java:
##########
@@ -130,6 +133,67 @@ void testFromIcebergTypeStruct() {
assertEquals(false, structType.fields()[1].nullable());
}
+ // -------------------------------------------------------------------------
+ // toIcebergSchema — complex types
+ // -------------------------------------------------------------------------
+
+ @Test
+ void testToIcebergSchemaWithListType() {
+ Column col =
+ GlueColumn.builder()
+ .withName("col_list")
+ .withType(Types.ListType.nullable(Types.StringType.get()))
+ .build();
+ Schema schema = GlueIcebergTableHelper.toIcebergSchema(new Column[] {col});
+
+ org.apache.iceberg.types.Types.NestedField field =
schema.findField("col_list");
+ assertInstanceOf(org.apache.iceberg.types.Types.ListType.class,
field.type());
+ org.apache.iceberg.types.Types.ListType listType =
+ (org.apache.iceberg.types.Types.ListType) field.type();
+ assertEquals(StringType.get(), listType.elementType());
Review Comment:
Avoid fully qualified Iceberg type names in the test body;
`NestedField`/`ListType` are already imported and there is no name collision
here. Using simple names matches the repo import convention and keeps the test
readable.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]