laskoviymishka commented on code in PR #2738:
URL: https://github.com/apache/iceberg-go/pull/2738#discussion_r4727741450
##########
io/gocloud/blobfs/blob_test.go:
##########
@@ -1182,6 +1182,54 @@ func TestBlobFileIORename(t *testing.T) {
assert.False(t, exists)
}
+func TestBlobFileIORenameSameObject(t *testing.T) {
+ t.Parallel()
+
+ for _, tt := range []struct {
+ name, oldPath, newPath string
+ }{
+ {"identical URI", "s3://test-bucket/data/source.parquet",
"s3://test-bucket/data/source.parquet"},
+ {"S3 scheme alias", "s3://test-bucket/data/source.parquet",
"s3a://test-bucket/data/source.parquet"},
+ {"URI and relative key",
"s3://test-bucket/data/source.parquet", "data/source.parquet"},
+ } {
+ t.Run(tt.name, func(t *testing.T) {
+ t.Parallel()
+
+ ctx := context.Background()
+ bucket := memblob.OpenBucket(nil)
+ t.Cleanup(func() { require.NoError(t, bucket.Close()) })
+
+ content := []byte("source")
+ require.NoError(t, bucket.WriteAll(ctx,
"data/source.parquet", content, nil))
+ bfs := testBlobFileIO(ctx, "test-bucket", bucket)
+
+ require.NoError(t, bfs.Rename(ctx, tt.oldPath,
tt.newPath))
+
+ data, err := bucket.ReadAll(ctx, "data/source.parquet")
+ require.NoError(t, err)
+ assert.Equal(t, content, data)
+ })
+ }
+}
+
+func TestBlobFileIORenameSameMissingObject(t *testing.T) {
Review Comment:
Is this one meant as a contract test for the error shape? With the base
`blob.go` it passes too, since base `Copy` of a missing key already went
through `blobErrToFsErr` with the same `PathError`. Only
`TestBlobFileIORenameSameObject` fails on base. Fine to keep it; a one-line
comment saying it pins the missing-source error would save the next reader from
treating it as a regression guard.
##########
io/gocloud/blobfs/blob.go:
##########
@@ -776,6 +776,16 @@ func (bfs *fileIO) Rename(ctx context.Context, oldpath,
newpath string) error {
return &fs.PathError{Op: "Rename", Path: newpath, Err: err}
}
+ // Two different URIs can resolve to the same object. Copying and then
Review Comment:
Could the `Rename` doc comment
([L763](https://github.com/apache/iceberg-go/blob/407760b7bf1e0bb23650017ca2a79ec2a4dd6896/io/gocloud/blobfs/blob.go#L763-L787))
cover this case? It still only says "replacing newpath if it already exists",
so callers can't tell that a same-key rename is a no-op. Something like:
```go
// Rename renames one file from oldpath to newpath, replacing newpath if it
// already exists. If both paths resolve to the same object key, the object
// is left in place and Rename returns nil, or fs.ErrNotExist if it is
missing.
```
--
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]