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


##########
partitions_test.go:
##########
@@ -61,6 +73,77 @@ func TestPartitionSpec(t *testing.T) {
        assert.Equal(t, 1002, spec3.LastAssignedFieldID())
 }
 
+func TestPartitionSpecCompatibleWithUsesTransformEquals(t *testing.T) {
+       spec := iceberg.NewPartitionSpec(iceberg.PartitionField{
+               SourceIDs: []int{1}, FieldID: 1001, Name: "id",
+               Transform: nonComparableTransform{values: []int{1, 2}},
+       })
+       sameTransformSpec := iceberg.NewPartitionSpec(iceberg.PartitionField{
+               SourceIDs: []int{1}, FieldID: 1002, Name: "id",
+               Transform: nonComparableTransform{values: []int{1, 2}},
+       })
+       differentTransformSpec := 
iceberg.NewPartitionSpec(iceberg.PartitionField{
+               SourceIDs: []int{1}, FieldID: 1003, Name: "id",
+               Transform: nonComparableTransform{values: []int{2, 3}},
+       })
+
+       var compatible bool
+       require.NotPanics(t, func() {
+               compatible = spec.CompatibleWith(&sameTransformSpec)
+       })
+       assert.True(t, compatible)
+
+       require.NotPanics(t, func() {
+               compatible = spec.CompatibleWith(&differentTransformSpec)
+       })
+       assert.False(t, compatible)

Review Comment:
   `require.NotPanics` records the panic but doesn't `FailNow`, so on a panic 
the stale `compatible` still flows into the `assert.True`/`assert.False` below 
and you get a confusing double failure. The two closures also share one `var 
compatible bool`, which reads like cross-closure capture and would race under 
`t.Parallel()`.
   
   I'd fold both into a single closure so the panic-safety check is 
unambiguously the thing under test:
   
   ```go
   require.NotPanics(t, func() {
        assert.True(t, spec.CompatibleWith(&sameTransformSpec))
        assert.False(t, spec.CompatibleWith(&differentTransformSpec))
   })
   ```
   
   While you're in here, a one-line comment on `nonComparableTransform` saying 
the `[]int` field is what makes it non-comparable — and what would have 
panicked under the old `==` — would make it clear this fixture is load-bearing.



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