badalprasadsingh commented on code in PR #524:
URL: https://github.com/apache/iceberg-go/pull/524#discussion_r2323976877


##########
exprs.go:
##########
@@ -482,8 +482,33 @@ func (b *boundRef[T]) Equals(other BoundTerm) bool {
 }
 
 func (b *boundRef[T]) Ref() BoundReference { return b }
-func (b *boundRef[T]) Field() NestedField  { return b.field }
-func (b *boundRef[T]) Type() Type          { return b.field.Type }
+
+func unwrapLogicalTypeValue(v any) any {
+       if m, ok := v.(map[string]any); ok {
+               if val, exists := m["long.timestamp-micros"]; exists {
+                       if microseconds, ok := val.(int64); ok {
+                               return Timestamp(microseconds)
+                       }
+               }
+
+               if val, exists := m["int.date"]; exists {
+                       if days, ok := val.(int32); ok {
+                               return days
+                       }
+               }
+
+               if val, exists := m["long.time-micros"]; exists {
+                       if microseconds, ok := val.(int64); ok {
+                               return Time(microseconds)
+                       }
+               }
+       }
+
+       return v

Review Comment:
   well, when we have a union schema like 
   ```json
   ["null", {"type": "int", "logicalType": "date"}]
   ```
   the Avro library needs to determine which type in the union to use when 
encoding a value. If you just pass a raw `int32` value, the library can't 
distinguish.
   
   That's the reason why we have:
   ```go
   return map[string]any{"int.date": int32(d)}
   ```
   in `convertDateValue` function. Thus, later on we have had to convert them 
back to `iceberg.Literal` formats



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