stevenzwu commented on a change in pull request #2410:
URL: https://github.com/apache/iceberg/pull/2410#discussion_r632136333
##########
File path: flink/src/test/java/org/apache/iceberg/flink/TestFlinkSchemaUtil.java
##########
@@ -270,4 +275,54 @@ private void checkInconsistentType(
Types.StructType.of(Types.NestedField.optional(0, "f0",
icebergExpectedType)),
FlinkSchemaUtil.convert(FlinkSchemaUtil.toSchema(RowType.of(flinkType))).asStruct());
}
+
+ @Test
+ public void testConvertFlinkSchemaBaseOnIcebergSchema() {
+ Schema baseSchema = new Schema(
+ Lists.newArrayList(
+ Types.NestedField.required(101, "int", Types.IntegerType.get()),
+ Types.NestedField.optional(102, "string", Types.StringType.get())
+ ),
+ Sets.newHashSet(101, 102)
+ );
+
+ TableSchema flinkSchema = TableSchema.builder()
+ .field("int", DataTypes.INT().notNull())
+ .field("string", DataTypes.STRING().nullable())
+ .primaryKey("int")
+ .build();
+ Schema convertedSchema = FlinkSchemaUtil.convert(baseSchema, flinkSchema);
+ Assert.assertEquals(baseSchema.asStruct(), convertedSchema.asStruct());
+ Assert.assertEquals(ImmutableSet.of(101),
convertedSchema.identifierFieldIds());
+ }
+
+ @Test
+ public void testConvertFlinkSchemaWithPrimaryKeys() {
+ Schema iSchema = new Schema(
Review comment:
nit: iSchema -> icebergSchema? It took me a few seconds to guess what
`i` stands for here :)
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]