twmb commented on code in PR #871:
URL: https://github.com/apache/iceberg-go/pull/871#discussion_r3076035574
##########
manifest.go:
##########
@@ -1817,62 +1785,57 @@ func (d *dataFile) initializeMapData() {
func (d *dataFile) convertAvroValueToIcebergType(v any, fieldID int) any {
if logicalType, ok := d.fieldIDToLogicalType[fieldID]; ok {
switch logicalType {
- case avro.Date:
+ case atype.Date:
+ // twmb/avro returns time.Time when the file schema has
logicalType,
+ // but raw int32 when the file schema omits it.
if val, ok := v.(time.Time); ok {
return Date(val.Truncate(24*time.Hour).Unix() /
int64((time.Hour * 24).Seconds()))
}
return Date(v.(int32))
- case avro.TimeMillis:
+ case atype.TimeMillis:
if val, ok := v.(time.Duration); ok {
return Time(val.Milliseconds())
}
return Time(v.(int64))
- case avro.TimeMicros:
+ case atype.TimeMicros:
if val, ok := v.(time.Duration); ok {
return Time(val.Microseconds())
}
return Time(v.(int64))
- case avro.TimestampMillis:
+ case atype.TimestampMillis:
if val, ok := v.(time.Time); ok {
return Timestamp(val.UTC().UnixMilli())
}
return Timestamp(v.(int64))
- case avro.TimestampMicros:
+ case atype.TimestampMicros:
if val, ok := v.(time.Time); ok {
return Timestamp(val.UTC().UnixMicro())
}
return Timestamp(v.(int64))
- case avro.Decimal:
- if unionMap, ok := v.(map[string]any); ok {
- if val, ok := unionMap["fixed"]; ok {
- if bigRatValue, ok := val.(*big.Rat);
ok {
- scale :=
d.fieldIDToFixedSize[fieldID]
- scaleFactor :=
new(big.Int).Exp(big.NewInt(10), big.NewInt(int64(scale)), nil)
- unscaled :=
new(big.Int).Mul(bigRatValue.Num(), scaleFactor)
- unscaled =
unscaled.Div(unscaled, bigRatValue.Denom())
- decimal128Val :=
decimal128.FromBigInt(unscaled)
-
- return DecimalLiteral{
- Scale: scale,
- Val: decimal128Val,
- }
- }
+ case atype.Decimal:
+ if numStr, ok := v.(json.Number); ok {
+ scale := d.fieldIDToFixedSize[fieldID]
Review Comment:
twmb/avro has been converted, done
--
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]