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


##########
table/partitioned_fanout_writer.go:
##########
@@ -80,48 +81,11 @@ type partitionExtractionPlan struct {
        pathPlan     partitionPathPlan
 }
 
-type (
-       binaryPartitionKey  string
-       float32PartitionKey uint32
-       float64PartitionKey uint64
-)
-
-const (
-       // Canonical NaN payloads make all NaNs of the same width compare equal.
-       // The width-specific key types preserve float width, while using raw 
bits
-       // intentionally keeps -0.0 and +0.0 distinct.
-       canonicalFloat32NaNBits uint32 = 0x7fc00000
-       canonicalFloat64NaNBits uint64 = 0x7ff8000000000000
-)
-
-func comparablePartitionKey(value any) any {
-       switch value := value.(type) {
-       case []byte:
-               return binaryPartitionKey(value)
-       case float32:
-               rawBits := math.Float32bits(value)
-               if math.IsNaN(float64(value)) {
-                       rawBits = canonicalFloat32NaNBits
-               }
-
-               return float32PartitionKey(rawBits)
-       case float64:
-               rawBits := math.Float64bits(value)
-               if math.IsNaN(value) {
-                       rawBits = canonicalFloat64NaNBits
-               }
-
-               return float64PartitionKey(rawBits)
-       }
-
-       return value
-}
-
 func partitionValuesEqual(left, right any) bool {
        // Supported partition values are primitive literals; []byte is 
converted to
        // a string key and float values are converted to comparable 
width-aware keys
        // above. The default branch preserves comparable scalar values.

Review Comment:
   Nit: "converted to comparable width-aware keys above". That conversion now 
lives in `tblutils.ComparablePartitionKey`, so "above" is stale. Maybe point at 
`ComparablePartitionKey` instead.



##########
table/internal/unified_partition_type.go:
##########
@@ -26,18 +26,15 @@ import (
        iceinternal "github.com/apache/iceberg-go/internal"
 )
 
-// unifiedPartitionType returns the table-wide partition type. It contains the
-// union of partition fields from every spec, which lets metadata tables
-// represent live files written before partition evolution.
-func unifiedPartitionType(metadata Metadata) (*iceberg.StructType, error) {
-       return unifiedPartitionTypeWithSchema(metadata, 
metadata.CurrentSchema())
-}
-
-func unifiedPartitionTypeWithSchema(
-       metadata Metadata,
+// UnifiedPartitionType returns the table-wide partition type for specs,
+// resolved against currentSchema. It contains the union of partition fields
+// from every spec, which lets metadata tables represent live files written
+// before partition evolution. specs is sorted in place, so callers pass a
+// copy such as Metadata.PartitionSpecs.
+func UnifiedPartitionType(
+       specs []iceberg.PartitionSpec,
        currentSchema *iceberg.Schema,
 ) (*iceberg.StructType, error) {
-       specs := metadata.PartitionSpecs()
        sort.Slice(specs, func(left, right int) bool {

Review Comment:
   Nit, non-blocking: before, this helper called `metadata.PartitionSpecs()` 
itself, so sorting in place was safe by construction. Now the doc comment asks 
callers to pass a copy. Both callers do today, but it's an easy contract to 
break later. Could this clone internally (`specs = slices.Clone(specs)`) and 
drop that sentence from the doc? Spec lists are tiny, so the copy costs nothing.



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