eneskeles commented on code in PR #2088:
URL: https://github.com/apache/iceberg-go/pull/2088#discussion_r4158210581
##########
literals.go:
##########
@@ -1529,9 +1529,17 @@ func (v VariantLiteral) To(typ Type) (Literal, error) {
return v, nil
}
- // TODO: improve by getting the actual value (using .Type()) and
attempting
- // to convert, or returning an error if it can't.
- return nil, fmt.Errorf("%w: VariantLiteral to %s", ErrBadCast, typ)
+ lit, ok := literalFromVariant(variant.Value(v))
+ if !ok {
+ return nil, fmt.Errorf("%w: VariantLiteral to %s", ErrBadCast,
typ)
+ }
+
+ out, err := lit.To(typ)
+ if err != nil {
Review Comment:
Here the wrapping is required because otherwise a caller might get an error
message without any mention of the `VariantLiteral`. For example `could not
cast value: Int32Literal to string`.
Happens when the variant holds a primitive but the primitive's cast fails.
For example
```go
leaf, found, _ := row.GetByPath(path.Field("measurement")) // 5 in most
rows, "n/a" in some
filter := iceberg.EqualTo(iceberg.Reference("some_integer_column"), leaf)
```
--
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]