diff --git a/paimon-core/src/main/java/org/apache/paimon/schema/SchemaValidation.java b/paimon-core/src/main/java/org/apache/paimon/schema/SchemaValidation.java index 1fd428a85187..3bd841460f88 100644 --- a/paimon-core/src/main/java/org/apache/paimon/schema/SchemaValidation.java +++ b/paimon-core/src/main/java/org/apache/paimon/schema/SchemaValidation.java @@ -120,7 +120,8 @@ public class SchemaValidation { ArrayType.class, RowType.class, MultisetType.class, - VectorType.class); + VectorType.class, + VariantType.class); /** * Validate the {@link TableSchema} and {@link CoreOptions}. diff --git a/paimon-core/src/test/java/org/apache/paimon/schema/SchemaManagerTest.java b/paimon-core/src/test/java/org/apache/paimon/schema/SchemaManagerTest.java index aed3a9a3099f..c080d0eef1e3 100644 --- a/paimon-core/src/test/java/org/apache/paimon/schema/SchemaManagerTest.java +++ b/paimon-core/src/test/java/org/apache/paimon/schema/SchemaManagerTest.java @@ -40,6 +40,7 @@ import org.apache.paimon.types.MapType; import org.apache.paimon.types.RowType; import org.apache.paimon.types.VarCharType; +import org.apache.paimon.types.VariantType; import org.apache.paimon.utils.ChangelogManager; import org.apache.paimon.utils.FailingFileIO; import org.apache.paimon.utils.SnapshotManager; @@ -588,6 +589,33 @@ public void testPartitionType() { MapType.class.getSimpleName(), "f0"); } + @Test + public void testVariantKeyType() { + final RowType variantType = + RowType.of(new VariantType(), new BigIntType(), new VarCharType()); + + final Schema variantPrimaryKeySchema = + new Schema(variantType.getFields(), partitionKeys, primaryKeys, options, ""); + assertThatThrownBy(() -> manager.createTable(variantPrimaryKeySchema)) + .isInstanceOf(UnsupportedOperationException.class) + .hasMessage( + "The type %s in primary key field %s is unsupported", + VariantType.class.getSimpleName(), "f0"); + + final Schema variantPartitionSchema = + new Schema( + variantType.getFields(), + partitionKeys, + Collections.emptyList(), + options, + ""); + assertThatThrownBy(() -> manager.createTable(variantPartitionSchema)) + .isInstanceOf(UnsupportedOperationException.class) + .hasMessage( + "The type %s in partition field %s is unsupported", + VariantType.class.getSimpleName(), "f0"); + } + @Test public void testChangelogTableWithFullCompaction() throws Exception { Map options = new HashMap<>();