nssalian commented on code in PR #932:
URL: https://github.com/apache/iceberg-go/pull/932#discussion_r3197733386
##########
literals.go:
##########
@@ -1389,3 +1392,39 @@ func (d *DecimalLiteral) UnmarshalBinary(data []byte)
error {
return nil
}
+
+type VariantLiteral struct {
+ val variant.Value
+}
+
+func (VariantLiteral) Comparator() Comparator[variant.Value] {
+ return func(v1, v2 variant.Value) int {
+ panic("variant values are not comparable")
+ }
+}
+
+func (VariantLiteral) Type() Type { return VariantType{} }
+func (v VariantLiteral) Value() variant.Value { return v.val }
+func (v VariantLiteral) Any() any { return v.val }
+func (v VariantLiteral) String() string { return "variant(...)" }
+
+func (v VariantLiteral) MarshalBinary() ([]byte, error) {
+ return v.val.Bytes(), nil
+}
+
+func (v VariantLiteral) To(typ Type) (Literal, error) {
+ if _, ok := typ.(VariantType); ok {
+ return v, nil
+ }
+
+ return nil, fmt.Errorf("%w: VariantLiteral to %s", ErrBadCast, typ)
+}
+
+func (v VariantLiteral) Equals(other Literal) bool {
+ rhs, ok := other.(VariantLiteral)
+ if !ok {
+ return false
+ }
+
+ return bytes.Equal(v.val.Bytes(), rhs.val.Bytes())
Review Comment:
```
func (v VariantLiteral) Equals(other Literal) bool {
rhs, ok := other.(VariantLiteral)
if !ok {
return false
}
lhs := variant.Value(v)
r := variant.Value(rhs)
return bytes.Equal(lhs.Metadata().Bytes(), r.Metadata().Bytes()) &&
bytes.Equal(lhs.Bytes(), r.Bytes())
}
```
Could I add this for the moment until we add support?
--
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]