public static TableSchema toSchema(RowType rowType) {
    TableSchema.Builder builder = TableSchema.builder();
    for (RowType.RowField field : rowType.getFields()) {
      builder.field(field.getName(), TypeConversions.fromLogicalToDataType(field.getType()));
    }
    return builder.build();
  }
@Test
  public void testConvertFlinkSchemaWithNestedColumnInPrimaryKeys() {
    Schema icebergSchema =
        new Schema(
            Lists.newArrayList(
                Types.NestedField.required(
                    1,
                    "struct",
                    Types.StructType.of(
                        Types.NestedField.required(2, "inner", Types.IntegerType.get())))),
            Sets.newHashSet(2));

    assertThatThrownBy(() -> FlinkSchemaUtil.toSchema(icebergSchema))
        .isInstanceOf(ValidationException.class)
        .hasMessageStartingWith("Could not create a PRIMARY KEY")
        .hasMessageContaining("Column 'struct.inner' does not exist.");
  }