lliangyu-lin commented on code in PR #530:
URL: https://github.com/apache/iceberg-go/pull/530#discussion_r2268248653


##########
table/snapshot_producers_internal_test.go:
##########
@@ -0,0 +1,110 @@
+package table
+
+import (
+       "context"
+       "fmt"
+       "github.com/apache/iceberg-go"
+       iceio "github.com/apache/iceberg-go/io"
+       "github.com/google/uuid"
+       "github.com/stretchr/testify/suite"
+       "path/filepath"
+       "strconv"
+       "strings"
+       "testing"
+)
+
+type DeleteFilesTestSuite struct {
+       suite.Suite
+
+       ctx         context.Context
+       tableSchema *iceberg.Schema
+       location    string
+
+       formatVersion int
+}
+
+func (t *DeleteFilesTestSuite) SetupSuite() {
+       t.ctx = context.Background()
+
+       t.tableSchema = iceberg.NewSchema(0,
+               iceberg.NestedField{ID: 1, Name: "foo", Type: 
iceberg.PrimitiveTypes.Bool},
+               iceberg.NestedField{ID: 2, Name: "bar", Type: 
iceberg.PrimitiveTypes.String},
+               iceberg.NestedField{ID: 3, Name: "baz", Type: 
iceberg.PrimitiveTypes.Int32},
+               iceberg.NestedField{ID: 4, Name: "qux", Type: 
iceberg.PrimitiveTypes.Date})
+}
+
+func (t *DeleteFilesTestSuite) SetupTest() {
+       t.location = filepath.ToSlash(strings.Replace(t.T().TempDir(), "#", "", 
-1))
+}
+
+func (t *DeleteFilesTestSuite) createTable(identifier Identifier, 
formatVersion int, spec iceberg.PartitionSpec, sc *iceberg.Schema) *Table {
+       meta, err := NewMetadata(sc, &spec, UnsortedSortOrder,
+               t.location, iceberg.Properties{"format-version": 
strconv.Itoa(formatVersion)})
+       t.Require().NoError(err)
+
+       return New(
+               identifier,
+               meta,
+               fmt.Sprintf("%s/metadata/%05d-%s.metadata.json", t.location, 1, 
uuid.New().String()),
+               func(ctx context.Context) (iceio.IO, error) {
+                       return iceio.LocalFS{}, nil
+               },
+               nil,
+       )
+}
+
+func (t *DeleteFilesTestSuite) TestEmptyTable() {
+       ident := Identifier{"default", "delete_files_table_empty_v" + 
strconv.Itoa(t.formatVersion)}
+       table := t.createTable(ident, t.formatVersion,
+               *iceberg.UnpartitionedSpec, t.tableSchema)
+
+       tx := table.NewTransaction()
+       updater := tx.updateSnapshot(iceio.LocalFS{}, nil).delete()
+       df := updater.producerImpl.(*deleteFiles)
+       err := df.computeDeletes(iceberg.EqualTo(iceberg.Reference("foo"), 
true), true)
+       t.Require().NoError(err)
+
+       updates, reqs, err := updater.commit()

Review Comment:
   Seems like we need an idiomatic way to override the commit in 
`snapshotUpdate`. When no entries were deleted, updates and requirements should 
be empty instead of creating a snapshot with no changes.
   
https://github.com/apache/iceberg-python/blob/main/pyiceberg/table/update/snapshot.py#L370-L373



-- 
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]

Reply via email to