xgbtxy commented on code in PR #2793:
URL: https://github.com/apache/iceberg-go/pull/2793#discussion_r4778615726


##########
visitors_test.go:
##########
@@ -1345,6 +1345,72 @@ func TestSanitizeExpression(t *testing.T) {
        }
 }
 
+func TestSanitizeExpressionBoundNestedField(t *testing.T) {

Review Comment:
   Updated `TestSanitizeExpressionBoundNestedField` to table-driven `t.Run` 
subtests in `bffb4f8`.



##########
visitors_test.go:
##########
@@ -1345,6 +1345,72 @@ func TestSanitizeExpression(t *testing.T) {
        }
 }
 
+func TestSanitizeExpressionBoundNestedField(t *testing.T) {
+       schema := iceberg.NewSchema(0,
+               iceberg.NestedField{
+                       ID:   1,
+                       Name: "user",
+                       Type: iceberg.NewStructType(
+                               iceberg.NestedField{ID: 2, Name: "email", Type: 
iceberg.PrimitiveTypes.String},
+                               iceberg.NestedField{ID: 3, Name: "id", Type: 
iceberg.PrimitiveTypes.Int64},
+                       ),
+               },
+       )

Review Comment:
   Added the `bound top-level literal control` case (`status`) in `bffb4f8`.



##########
visitors_test.go:
##########
@@ -1345,6 +1345,72 @@ func TestSanitizeExpression(t *testing.T) {
        }
 }
 
+func TestSanitizeExpressionBoundNestedField(t *testing.T) {
+       schema := iceberg.NewSchema(0,
+               iceberg.NestedField{
+                       ID:   1,
+                       Name: "user",
+                       Type: iceberg.NewStructType(
+                               iceberg.NestedField{ID: 2, Name: "email", Type: 
iceberg.PrimitiveTypes.String},
+                               iceberg.NestedField{ID: 3, Name: "id", Type: 
iceberg.PrimitiveTypes.Int64},
+                       ),
+               },
+       )
+
+       // Bound nested literal predicate preserves full dotted column path and 
redacts literal.
+       boundEq, err := iceberg.BindExpr(schema, 
iceberg.EqualTo(iceberg.Reference("user.email"), "[email protected]"), true)
+       require.NoError(t, err)
+       sanitized, err := iceberg.SanitizeExpression(boundEq)
+       require.NoError(t, err)
+
+       raw, err := json.Marshal(sanitized)
+       require.NoError(t, err)
+       assert.JSONEq(t, 
`{"type":"eq","term":"user.email","value":"(redacted)"}`, string(raw))
+       assert.NotContains(t, string(raw), "[email protected]")
+
+       // Bound nested set predicate preserves full dotted column path and 
arity.
+       boundIn, err := iceberg.BindExpr(schema, 
iceberg.IsIn(iceberg.Reference("user.id"), int64(10), int64(20)), true)
+       require.NoError(t, err)
+       sanitized, err = iceberg.SanitizeExpression(boundIn)
+       require.NoError(t, err)
+
+       raw, err = json.Marshal(sanitized)
+       require.NoError(t, err)
+       assert.JSONEq(t, 
`{"type":"in","term":"user.id","values":["(redacted)-1","(redacted)-2"]}`, 
string(raw))
+
+       // Bound nested unary predicate preserves full dotted column path.
+       boundNull, err := iceberg.BindExpr(schema, 
iceberg.IsNull(iceberg.Reference("user.email")), true)
+       require.NoError(t, err)
+       sanitized, err = iceberg.SanitizeExpression(boundNull)
+       require.NoError(t, err)
+
+       raw, err = json.Marshal(sanitized)
+       require.NoError(t, err)
+       assert.JSONEq(t, `{"type":"is-null","term":"user.email"}`, string(raw))
+
+       // Bound transform over nested field preserves full dotted column path.
+       boundTf, err := iceberg.BindExpr(schema,
+               
iceberg.EqualTo(iceberg.NewUnboundTransform(iceberg.BucketTransform{NumBuckets: 
16}, iceberg.Reference("user.id")), int32(5)),
+               true)
+       require.NoError(t, err)
+       sanitized, err = iceberg.SanitizeExpression(boundTf)
+       require.NoError(t, err)
+
+       raw, err = json.Marshal(sanitized)
+       require.NoError(t, err)
+       assert.JSONEq(t, 
`{"type":"eq","term":{"type":"transform","transform":"bucket[16]","term":"user.id"},"value":"(redacted)"}`,
 string(raw))
+
+       // Case-insensitive bound reference resolves to canonical nested column 
path.
+       boundCI, err := iceberg.BindExpr(schema, 
iceberg.EqualTo(iceberg.Reference("USER.EMAIL"), "[email protected]"), false)

Review Comment:
   Agreed that canonical schema path is better here — added a comment on the 
case-insensitive subtest in `bffb4f8` noting this intentional difference from 
Iceberg Java's caller-spelling preservation.



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