zeroshade commented on code in PR #1972:
URL: https://github.com/apache/iceberg-go/pull/1972#discussion_r3937951988


##########
manifest_projection.go:
##########
@@ -0,0 +1,220 @@
+// 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 iceberg
+
+import (
+       "errors"
+       "fmt"
+       "iter"
+       "slices"
+
+       iceio "github.com/apache/iceberg-go/io"
+       lru "github.com/hashicorp/golang-lru/v2"
+       "github.com/twmb/avro"
+)
+
+// ManifestEntryProjection selects the optional data-file fields decoded while

Review Comment:
   **major** — IncludeColumnStats=true still drops column_sizes, and rewriting 
a projected entry silently loses it with no error
   
   ManifestEntryProjection.IncludeColumnStats reads as an all-stats toggle, but 
manifestScanDataFileField (manifest_projection.go:157-170) returns false for 
column_sizes and distinct_counts unconditionally. The exported surface added by 
this PR -- EntriesWithProjection (manifest_projection.go:63), 
NewManifestReaderWithProjection (manifest.go:715), DataFileWithoutColumnStats, 
ManifestEntryWithoutColumnStats -- can therefore hand a lossy DataFile to a 
ManifestWriter, which re-serializes it via cloneDataFileAvroFields 
(manifest.go:1973) and persists the loss without any error or guard. The 'must 
not be passed to a ManifestWriter' contract is documentation-only and pinned by 
no test. This is NOT reachable on the shipped internal path (only 
ToArrowRecords calls planFiles(ctx,true), and 
compaction/transaction.go/row_delta.go all use unprojected PlanFiles), so it is 
not blocking -- but it is permanent public API. Suggest unexporting these 
helpers, or having the writer reject entries flagged
  as projected, or renaming the field to reflect that column_sizes is never 
included.
   
   <details><summary>Evidence</summary>
   
   ```text
   Probe pr1972_probe_test.go (root pkg), run and then removed: 'unprojected 
read: valueCounts=map[1:10] colSizes=map[1:512]'; 'projected read 
(IncludeColumnStats=true): valueCounts=map[1:10] colSizes=map[]'; 'after 
rewrite of projected entry: colSizes=map[]'; 'CONFIRMED SILENT LOSS: 
column_sizes map[1:512] -> map[] with no error'. WriteManifest returned nil 
error on the projected entry.
   ```
   
   </details>



##########
table/scanner.go:
##########
@@ -1164,6 +1193,34 @@ func (scan *Scan) 
collectManifestEntriesWithSchemaMinSequenceNum(
        return flattenClassifiedManifestEntries(manifestResults), nil
 }
 
+func (scan *Scan) manifestProjectionForManifest(
+       manifest iceberg.ManifestFile,
+       retainDataFileStats bool,
+) (iceberg.ManifestEntryProjection, bool) {

Review Comment:
   **minor** — ManifestContentDeletes clause and 
manifestProjectionRetainsDataStats are tautological at every call site
   
   In manifestProjectionForManifest the `manifest.ManifestContent() == 
iceberg.ManifestContentDeletes` disjunct can never decide the result. Call site 
1 (collectManifestEntriesWithSchemaMinSequenceNum, scanner.go:1637) is only 
reached under `if len(deleteManifests) > 0` with an all-Deletes list, so 
retainDataFileStats = manifestProjectionRetainsDataStats(deleteManifests) is 
already unconditionally true. Call site 2 (planDataManifestTasksWithOptions) 
only ever receives dataManifests, which splitManifestList guarantees contain no 
Deletes manifests. So manifestProjectionRetainsDataStats always returns true 
where it is used. TestManifestProjectionRetainsDataFileStatsForDeleteScans pins 
a mixed [dataManifest, deleteManifest] list that cannot occur in production, so 
it does not compensate. Consider collapsing the condition or documenting why 
the defensive clause is kept.



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