You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2021/03/15 07:43:53 UTC

[GitHub] [iceberg] openinx opened a new issue #2334: Test: Add row-level API for TestTable to make the unit test more easy.

openinx opened a new issue #2334:
URL: https://github.com/apache/iceberg/issues/2334


   Currently,  we only provide the file-level API to execute the row-level delete/update/insert for `TestTable`,  that means we have to write few deletes by operating low-level API like the following: 
   
   ```java
   Schema deleteRowSchema = icebergTableUnPartitioned.schema().select("data");
       Record dataDelete = GenericRecord.create(deleteRowSchema);
   
       List<Record> deletions = Lists.newArrayList(
           dataDelete.copy("data", "BBB"), // id = 2
           dataDelete.copy("data", "EEE"), // id = 5
           dataDelete.copy("data", "HHH")  // id = 8
       );
       DeleteFile eqDeletes = FileHelpers.writeDeleteFile(icebergTableUnPartitioned, newOutputFile(),
           deletions, deleteRowSchema);
   
       icebergTableUnPartitioned.newRowDelta()
           .addDeletes(eqDeletes)
           .commit();
   
       assertSetsEqual(Lists.newArrayList(
           Row.of(1, "AAA"),
           Row.of(3, "CCC"),
           Row.of(4, "DDD"),
           Row.of(6, "FFF"),
           Row.of(7, "GGG"),
           Row.of(9, "III")),
           sql("SELECT * FROM %s", TABLE_NAME_UNPARTITIONED)
       );
   ```
   
   I think there will be many row-level delete unit tests in future development.  It will be more friendly if we could provide a row-level delete API in `TestTable` such as: 
   
   
   ```java
   Table table = new TestTable(...);
   table.newRowChanges()
        .addDeletes(row1, row2)
        .insert(row3)
        .commit() 
   ```
   
   That will be only exposed for testing purpose,  don't have to expose such API to end-users.


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org