laskoviymishka commented on code in PR #2739:
URL: https://github.com/apache/iceberg-go/pull/2739#discussion_r4727737489


##########
table/changelog_scan_task.go:
##########
@@ -193,13 +193,19 @@ func (t DeletedRowsScanTask) ExistingDeletes() 
[]iceberg.DataFile {
 }
 
 func fileScanTaskWithDeletes(dataFile iceberg.DataFile, deletes 
[]iceberg.DataFile) (FileScanTask, error) {
+       if dataFile == nil {

Review Comment:
   This only catches an untyped nil. A typed-nil `DataFile` passes the check 
and then panics at `dataFile.FileSizeBytes()` a few lines down 
([`manifest.go#L2933`](https://github.com/apache/iceberg-go/blob/05d04af1a3cb94f769fc72b069bbec465083eb8a/manifest.go#L2933)
 dereferences the receiver), where `main` just stored it. Since `*dataFile` is 
unexported this is hard to reach, so is a doc line on the constructors enough 
here?



##########
table/changelog_scan_task_range_test.go:
##########
@@ -0,0 +1,62 @@
+// 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
+
+import (
+       "testing"
+
+       "github.com/apache/iceberg-go"
+       "github.com/stretchr/testify/require"
+)
+
+func TestChangelogTaskConstructorsInitializeFullFileRangeAndRowLineage(t 
*testing.T) {

Review Comment:
   Could this test live in the existing `changelog_scan_task_test.go`? That 
file already covers the same three constructors 
([L37-L104](https://github.com/apache/iceberg-go/blob/05d04af1a3cb94f769fc72b069bbec465083eb8a/table/changelog_scan_task_test.go#L37-L104))
 and has a `changelogTestDataFile` helper, so we'd keep one test file per 
source file.



##########
table/changelog_scan_task_range_test.go:
##########
@@ -0,0 +1,62 @@
+// 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
+
+import (
+       "testing"
+
+       "github.com/apache/iceberg-go"
+       "github.com/stretchr/testify/require"
+)
+
+func TestChangelogTaskConstructorsInitializeFullFileRangeAndRowLineage(t 
*testing.T) {
+       builder, err := iceberg.NewDataFileBuilder(*iceberg.UnpartitionedSpec,
+               iceberg.EntryContentData, "data/lineage.parquet", 
iceberg.ParquetFile,
+               nil, nil, nil, 10, 1024)
+       require.NoError(t, err)
+       data := builder.FirstRowID(123).Build()
+
+       constructors := []struct {
+               name    string
+               newTask func(iceberg.DataFile) (ChangelogScanTask, error)
+       }{
+               {"added rows", func(file iceberg.DataFile) (ChangelogScanTask, 
error) {
+                       return NewAddedRowsScanTask(file, nil, 0, 1)
+               }},
+               {"deleted data file", func(file iceberg.DataFile) 
(ChangelogScanTask, error) {
+                       return NewDeletedDataFileScanTask(file, nil, 0, 1)
+               }},
+               {"deleted rows", func(file iceberg.DataFile) 
(ChangelogScanTask, error) {
+                       return NewDeletedRowsScanTask(file, nil, nil, 0, 1)
+               }},
+       }
+
+       for _, tc := range constructors {
+               t.Run(tc.name, func(t *testing.T) {
+                       task, err := tc.newTask(data)
+                       require.NoError(t, err)
+                       scan := task.ScanTask()
+                       require.Equal(t, int64(0), scan.Start)
+                       require.Equal(t, data.FileSizeBytes(), scan.Length)
+                       require.Equal(t, data.FirstRowID(), scan.FirstRowID)
+
+                       _, err = tc.newTask(nil)

Review Comment:
   Could the nil-file check get its own `t.Run`? Sharing the subtest with the 
range and lineage asserts means an earlier `require` failure hides it.



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