xitongsys / parquet-go

pure golang library for reading/writing parquet file
Apache License 2.0
1.27k stars 293 forks source link

MarshalFast can't handle doubly nested types #527

Open yizzlez opened 1 year ago

yizzlez commented 1 year ago

MarshalFast cannot handle doubly nested types. The below test fails:

func TestMarshalFastWithDoubleNestedType(t *testing.T) {
    type Tag struct {
        Key string `parquet:"name=key, type=BYTE_ARRAY"`
    }
    type Span struct {
        Tags []Tag `parquet:"name=tags, type=LIST"`
    }
    type Trace struct {
        Spans []Span `parquet:"name=spans, type=LIST"`
    }

    span1 := Span{
        Tags: []Tag{
            {"foo"},
            {"bar"},
        },
    }
    span2 := Span{
        Tags: []Tag{
            {"baz"},
        },
    }

    traces := []interface{}{
        Trace{
            Spans: []Span{span1, span2},
        },
    }

    sch, err := schema.NewSchemaHandlerFromStruct(new(Trace))
    if err != nil {
        t.Fatalf("%v", err)
    }
    expected, err := marshal.Marshal(traces, sch)
    actual, err := MarshalFast(traces, sch)
    if !reflect.DeepEqual(expected, actual) {
        t.Errorf("not equal")
    }
}
Arnold1 commented 1 year ago

hi, do single nested type work?