alexandre-normand commented on code in PR #718:
URL: https://github.com/apache/iceberg-go/pull/718#discussion_r2790899791
##########
table/table_test.go:
##########
@@ -1663,6 +1664,55 @@ func (t *TableWritingTestSuite) TestOverwriteRecord() {
t.Equal(table.OpAppend, snapshot.Summary.Operation) // Empty table
overwrite becomes append
}
+// TestDelete verifies that Table.Delete properly delegates to
Transaction.Delete
+func (t *TableWritingTestSuite) TestDelete() {
+ testCases := []struct {
+ name string
+ table *table.Table
+ expectedErr error
+ }{
+ {
+ name: "success with copy-on-write",
+ table: t.createTable(
+ table.Identifier{"default",
"overwrite_record_wrapper_v" + strconv.Itoa(t.formatVersion)},
+ t.formatVersion,
+ *iceberg.UnpartitionedSpec,
+ t.tableSchema,
+ ),
+ expectedErr: nil,
+ },
+ {
+ name: "abort on merge-on-read",
+ table: t.createTableWithProps(
+ table.Identifier{"default",
"overwrite_record_wrapper_v" + strconv.Itoa(t.formatVersion)},
+ map[string]string{
+ table.PropertyFormatVersion:
strconv.Itoa(t.formatVersion),
+ table.WriteDeleteModeKey:
table.WriteModeMergeOnRead,
+ },
+ t.tableSchema,
+ ),
+ expectedErr: errors.New("only 'copy-on-write' is
currently supported"),
+ },
+ }
+
+ for _, tc := range testCases {
+ t.Run(tc.name, func() {
+ resultTbl, err := tc.table.Delete(t.ctx,
iceberg.EqualTo(iceberg.Reference("foo"), "bar"), nil)
+
+ // If an error was expected, check that it's the
correct one and abort validating the operation
+ if tc.expectedErr != nil {
+ t.Require().ErrorContains(err,
tc.expectedErr.Error())
+
+ return
+ }
+
+ snapshot := resultTbl.CurrentSnapshot()
+ t.NotNil(snapshot)
+ t.Equal(table.OpAppend, snapshot.Summary.Operation) //
Empty table overwrite becomes append
Review Comment:
Ah yes, I completely missed this in doing copy-pasta. It was actually
wrongly set to OpAppend but I fixed that in
6ff00fb003dce8a9ac68b48b1a444f580f2ca668. I added operation to `snapshotUpdate`
which I'm not 100% is the best way to do this but let me know what you think.
--
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]