laskoviymishka commented on code in PR #779:
URL: https://github.com/apache/iceberg-go/pull/779#discussion_r2937449877


##########
table/arrow_utils.go:
##########
@@ -715,6 +716,45 @@ func retOrPanic[T any](v T, err error) T {
        return v
 }
 
+// writeDefaultToScalar converts an Iceberg write-default value to an Arrow 
scalar.
+func writeDefaultToScalar(v any, t iceberg.Type, dt arrow.DataType) 
scalar.Scalar {
+       switch t.(type) {
+       case iceberg.DateType:
+               return scalar.NewDate32Scalar(arrow.Date32(v.(iceberg.Date)))

Review Comment:
   To clarify the remaining work here: writeDefaultToScalar needs to handle the 
actual runtime types that appear after JSON deserialization (float64, string, 
json.Number), not just the Go-native Iceberg types. 
   
   For example:
   - iceberg.Date → may arrive as float64 from JSON, needs int32(v.(float64))
   - uuid.UUID → may arrive as string, needs uuid.Parse(v.(string))
   - iceberg.Timestamp → may arrive as float64
   - iceberg.Decimal → check how it's deserialized in the schema JSON path
   
   Each case in the switch should handle both the typed Iceberg value (from 
programmatic construction) and the JSON-deserialized form. Use type switches on 
v within each case to handle both, and panic with fmt.Errorf including the 
field type, Go type of v, and value if the conversion fails.
   
   Also, narrow the extension type check to *extensions.UUIDType specifically, 
as I mentioned earlier.



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