nssalian commented on code in PR #17500:
URL: https://github.com/apache/iceberg/pull/17500#discussion_r3738922085


##########
core/src/test/java/org/apache/iceberg/catalog/CatalogTests.java:
##########
@@ -966,6 +971,71 @@ public void testLoadTable() {
         .containsAll(properties.entrySet());
   }
 
+  @Test
+  public void testCreateTableWithVariantColumn() {
+    assumeThat(supportsVariant()).as("Catalog supports the variant 
type").isTrue();
+
+    C catalog = catalog();
+
+    if (requiresNamespaceCreate()) {
+      catalog.createNamespace(TBL.namespace());
+    }
+
+    assertThat(catalog.tableExists(TBL)).as("Table should not 
exist").isFalse();
+
+    Schema variantSchema =
+        new Schema(
+            required(1, "id", Types.LongType.get()),
+            optional(2, "data", Types.VariantType.get()),
+            optional(3, "list_data", Types.ListType.ofOptional(5, 
Types.VariantType.get())),
+            optional(
+                4,
+                "map_data",
+                Types.MapType.ofOptional(6, 7, Types.StringType.get(), 
Types.VariantType.get())));
+
+    catalog
+        .buildTable(TBL, variantSchema)
+        .withLocation(baseTableLocation(TBL))
+        .withProperty(TableProperties.FORMAT_VERSION, "3")
+        .create();
+
+    assertThat(catalog.tableExists(TBL)).as("Table should exist").isTrue();
+
+    Table loaded = catalog.loadTable(TBL);
+    assertThat(loaded.schema().asStruct())
+        .as("Variant columns should round-trip through the catalog")
+        .isEqualTo(variantSchema.asStruct());
+    assertThat(TableUtil.formatVersion(loaded))
+        .as("Table with a variant column must be format version 3")
+        .isEqualTo(3);
+  }
+
+  @Test
+  public void testCreateV2TableWithVariantColumnFails() {
+    assumeThat(supportsVariant()).as("Catalog supports the variant 
type").isTrue();
+
+    C catalog = catalog();
+
+    if (requiresNamespaceCreate()) {
+      catalog.createNamespace(TBL.namespace());
+    }
+
+    Schema variantSchema =
+        new Schema(
+            required(1, "id", Types.LongType.get()), optional(2, "data", 
Types.VariantType.get()));
+
+    assertThatThrownBy(
+            () ->
+                catalog
+                    .buildTable(TBL, variantSchema)
+                    .withLocation(baseTableLocation(TBL))
+                    .withProperty(TableProperties.FORMAT_VERSION, "2")
+                    .create())
+        .hasMessageContaining("is not supported until v3");

Review Comment:
   Ok. Let me remove it to simplify.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to