Hi, all:
I want to try row level delete, but get the exception : IllegalArgumentException: Cannot write delete files in a v1 table. I look over https://iceberg.apache.org/spec/#table-metadata for format-version, it said that An integer version number for the format. Currently, this is always 1. Implementations must throw an exception if a table’s version is higher than the supported version. so what can i do to test row-level deletion ? So what can I do to have a try to row level delete? how to create a v2 table ? thx Code is : private static void deleteRead() throws IOException { Schema deleteRowSchema = table.schema().select("id"); Record dataDelete = GenericRecord.create(deleteRowSchema); List<Record> dataDeletes = Lists.newArrayList( dataDelete.copy("id", 11), // id = 29 dataDelete.copy("id", 12), // id = 89 dataDelete.copy("id", 13) // id = 122 ); DeleteFile eqDeletes = writeDeleteFile(table, Files.localOutput(tmpFile), dataDeletes, deleteRowSchema); table.newRowDelta() .addDeletes(eqDeletes) .commit(); } private static DeleteFile writeDeleteFile(Table table, OutputFile out, List<Record> deletes, Schema deleteRowSchema) throws IOException { EqualityDeleteWriter<Record> writer = Parquet.writeDeletes(out) .forTable(table) .withPartition(Row.of("20201221")) .rowSchema(deleteRowSchema) .createWriterFunc(GenericParquetWriter::buildWriter) .overwrite() .equalityFieldIds(deleteRowSchema.columns().stream().mapToInt(Types.NestedField::fieldId).toArray()) .buildEqualityWriter(); try (Closeable toClose = writer) { writer.deleteAll(deletes); } return writer.toDeleteFile(); } | | liubo07199 | | liubo07...@hellobike.com |