github.com/parquet-go/parquet-go@v0.20.0/format/parquet_test.go (about)

     1  package format_test
     2  
     3  import (
     4  	"reflect"
     5  	"testing"
     6  
     7  	"github.com/parquet-go/parquet-go/format"
     8  	"github.com/segmentio/encoding/thrift"
     9  )
    10  
    11  func TestMarshalUnmarshalSchemaMetadata(t *testing.T) {
    12  	protocol := &thrift.CompactProtocol{}
    13  	metadata := &format.FileMetaData{
    14  		Version: 1,
    15  		Schema: []format.SchemaElement{
    16  			{
    17  				Name: "hello",
    18  			},
    19  		},
    20  		RowGroups: []format.RowGroup{},
    21  	}
    22  
    23  	b, err := thrift.Marshal(protocol, metadata)
    24  	if err != nil {
    25  		t.Fatal(err)
    26  	}
    27  
    28  	decoded := &format.FileMetaData{}
    29  	if err := thrift.Unmarshal(protocol, b, &decoded); err != nil {
    30  		t.Fatal(err)
    31  	}
    32  
    33  	if !reflect.DeepEqual(metadata, decoded) {
    34  		t.Error("values mismatch:")
    35  		t.Logf("expected:\n%#v", metadata)
    36  		t.Logf("found:\n%#v", decoded)
    37  	}
    38  }