zeroshade opened a new issue, #2093:
URL: https://github.com/apache/iceberg-go/issues/2093

   **Problem**
   
   `literalSet.addliteral` keys most literals by the literal itself 
(utils.go:141 on main: `l[v] = struct{ orig Literal }{}`). `VariantLiteral` is 
a `variant.Value`, which holds `[]byte`, so it isn't comparable and the map 
insert panics. `SetPredicate` builds that set whenever it gets two or more 
literals (exprs.go:911), so `IsIn`/`NotIn` with variant values panic at 
construction, even though `LiteralType` admits `variant.Value`. A single value 
only works because `SetPredicate` folds it into `EqualTo`/`NotEqualTo`.
   
   Binary, fixed and geo literals already avoid this by keying on 
`maphash.Bytes` (utils.go:131-139, and the matching cases in `Contains`).
   
   **Reproduction**
   
   ```go
   build := func(v any) variant.Value {
        var b variant.Builder
        _ = b.Append(v)
        val, _ := b.Build()
        return val
   }
   
   iceberg.IsIn(iceberg.Reference("x"), build(int64(1)), build(int64(2)))
   ```
   
   On main (dd935d8):
   
   ```
   panic: runtime error: hash of unhashable type iceberg.VariantLiteral
   github.com/apache/iceberg-go.literalSet.addliteral(...)
        utils.go:141
   github.com/apache/iceberg-go.newLiteralSet(...)
        utils.go:125
   github.com/apache/iceberg-go.SetPredicate(...)
        exprs.go:911
   github.com/apache/iceberg-go.IsIn[...](...)
        predicates.go:61
   ```
   
   Expected: an unbound set predicate. With #2088, binding it against a 
primitive column converts each value the same way `EqualTo` does.
   
   **Proposed fix**
   
   Add a `VariantLiteral` case to `addliteral` and `Contains` that keys on a 
hash of the metadata and value bytes (the bytes `VariantLiteral.Equals` 
compares) and confirms with `Equals`, like the binary/fixed/geo cases. Hashing 
only the value bytes isn't enough, since object field IDs index into the 
metadata dictionary. Add a test that builds and binds `IsIn` with two variant 
values.
   
   **Related**
   
   - #2088 / #2081: `VariantLiteral.To` now converts primitive variants, so set 
predicates over variant values become usable
   


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