badalprasadsingh commented on code in PR #2639:
URL: https://github.com/apache/iceberg-go/pull/2639#discussion_r4624605704
##########
table/rolling_data_writer_test.go:
##########
@@ -590,7 +610,7 @@ func (s *RollingDataWriterTestSuite)
TestStreamErrorRemovesWriterFromFactory() {
defer factory.closeAll()
outputCh := make(chan iceberg.DataFile, 10)
- writer, err := factory.getOrCreateRollingDataWriter(s.ctx, "", nil,
outputCh)
+ writer, err := factory.getOrCreateRollingDataWriter(s.ctx, "", nil,
outputCh, factory.currentSpec)
Review Comment:
this test still calls "factory.writers.Load("")" (check lin628), but the map
keys are now "rollingWriterKey", so "ok" is always false. the check passes even
if the stream stops removing the writer
better: please use the writer's key, as your new test does:
```go
_, ok := factory.writers.Load(writer.key)
```
##########
table/arrow_utils.go:
##########
@@ -2444,7 +2444,16 @@ func positionDeleteRecordsToDataFiles(ctx
context.Context, rootLocation string,
targetFileSize :=
int64(meta.props.GetInt(WriteDeleteTargetFileSizeBytesKey,
WriteDeleteTargetFileSizeBytesDefault))
- if latestMetadata.PartitionSpec().IsUnpartitioned() {
+ currentSpec := latestMetadata.PartitionSpec()
+ useUnpartitionedWriter := currentSpec.IsUnpartitioned()
+ for _, partition := range partitionContextByFilePath {
+ if int(partition.specID) != currentSpec.ID() {
+ useUnpartitionedWriter = false
+
+ break
+ }
+ }
Review Comment:
nit: a short comment on why would help here: the unpartitioned writer stamps
the current spec on every file, so it is safe only when every target-file was
written under that spec
without it, someone may simplify this back to "IsUnpartitioned()"
##########
table/pos_delete_spec_evolution_test.go:
##########
@@ -0,0 +1,98 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package table_test
+
+import (
+ "context"
+ "path/filepath"
+ "testing"
+
+ "github.com/apache/arrow-go/v18/arrow/array"
+ "github.com/apache/arrow-go/v18/arrow/memory"
+ "github.com/apache/iceberg-go"
+ iceio "github.com/apache/iceberg-go/io"
+ "github.com/apache/iceberg-go/table"
+ "github.com/stretchr/testify/require"
+)
+
+func TestPositionDeleteAfterSpecEvolution(t *testing.T) {
+ for _, tc := range []struct {
+ name string
+ mixed, unpartitioned bool
+ }{
+ {name: "old-spec"},
+ {name: "mixed-specs", mixed: true},
+ {name: "evolve-to-unpartitioned", mixed: true, unpartitioned:
true},
+ } {
Review Comment:
in every case the two specs write different partition paths, so only the
unit test covers the spec id in the writer key
better: add a case where they share one, eg: "truncate[2](cat)" replaced by
"truncate[4](cat)", both named c, with cat = "ab" rows before and after
--
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]