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


##########
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)))
+       case iceberg.TimeType:
+               return scalar.NewTime64Scalar(arrow.Time64(v.(iceberg.Time)), 
dt)
+       case iceberg.TimestampType, iceberg.TimestampTzType:
+               return 
scalar.NewTimestampScalar(arrow.Timestamp(v.(iceberg.Timestamp)), dt)
+       case iceberg.TimestampNsType, iceberg.TimestampTzNsType:
+               return 
scalar.NewTimestampScalar(arrow.Timestamp(v.(iceberg.TimestampNano)), dt)
+       case iceberg.UUIDType:
+               u := v.(uuid.UUID)
+
+               return retOrPanic(scalar.MakeScalarParam(u[:], 
&arrow.FixedSizeBinaryType{ByteWidth: 16}))
+       case iceberg.DecimalType:
+               d := v.(iceberg.Decimal)
+
+               return scalar.NewDecimal128Scalar(d.Val, dt)
+       default:
+               return retOrPanic(scalar.MakeScalarParam(v, dt))

Review Comment:
   fair, seems like visitor will catch this panic and wrap in proper error. 
   writeDefaultToArray should panic with a descriptive fmt.Errorf(...) and 
Visit will catch it.



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