nssalian commented on code in PR #932:
URL: https://github.com/apache/iceberg-go/pull/932#discussion_r3197273459


##########
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)
+}

Review Comment:
   Let me see what I can do better here else I'll leave a todo for later.



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