You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by ze...@apache.org on 2025/02/21 22:11:15 UTC
(iceberg-go) 03/06: Add support for new types when converting Iceberg -> Avro schema
This is an automated email from the ASF dual-hosted git repository.
zeroshade pushed a commit to branch fix-manifest-entry-partition-schema
in repository https://gitbox.apache.org/repos/asf/iceberg-go.git
commit 4a58797ee72e7fbc6c40f45121e498f897bd4382
Author: Arnaud Briche <br...@gmail.com>
AuthorDate: Tue Feb 18 11:17:24 2025 +0100
Add support for new types when converting Iceberg -> Avro schema
---
utils.go | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/utils.go b/utils.go
index 597babe..1bd85dc 100644
--- a/utils.go
+++ b/utils.go
@@ -272,7 +272,10 @@ func nestedFieldToAvroField(f NestedField) (*avro.Field, error) {
}
func nestedFieldToAvroSchema(f NestedField) (avro.Schema, error) {
- var sch avro.Schema
+ var (
+ sch avro.Schema
+ err error
+ )
switch f.Type.(type) {
case *StringType:
@@ -291,10 +294,30 @@ func nestedFieldToAvroSchema(f NestedField) (avro.Schema, error) {
sch = avro.NewPrimitiveSchema(avro.Double, nil)
case *DateType:
sch = avro.NewPrimitiveSchema(avro.Int, avro.NewPrimitiveLogicalSchema(avro.Date))
+ case *TimeType:
+ sch = avro.NewPrimitiveSchema(avro.Long, avro.NewPrimitiveLogicalSchema(avro.TimeMicros))
+ case *TimestampType:
+ sch = avro.NewPrimitiveSchema(
+ avro.Long,
+ avro.NewPrimitiveLogicalSchema(avro.TimeMicros),
+ avro.WithProps(map[string]any{"adjust-to-utc": false}),
+ )
+ case *TimestampTzType:
+ sch = avro.NewPrimitiveSchema(
+ avro.Long,
+ avro.NewPrimitiveLogicalSchema(avro.TimeMicros),
+ avro.WithProps(map[string]any{"adjust-to-utc": true}),
+ )
+ case *UUIDType:
+ sch, err = avro.NewFixedSchema("uuid_fixed", "", 16, avro.NewPrimitiveLogicalSchema(avro.UUID))
default:
return nil, fmt.Errorf("unsupported Iceberg type: %s", f.Type.String())
}
+ if err != nil {
+ return nil, err
+ }
+
if !f.Required {
return avro.NewUnionSchema([]avro.Schema{
avro.NewNullSchema(),