Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions parquet/pqarrow/file_writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func TestFileWriterTotalBytes(t *testing.T) {

// Verify total bytes & compressed bytes are correct
assert.Equal(t, int64(408), writer.TotalCompressedBytes())
assert.Equal(t, int64(912), writer.TotalBytesWritten())
assert.Equal(t, int64(910), writer.TotalBytesWritten())
}

func TestFileWriterTotalBytesBuffered(t *testing.T) {
Expand Down Expand Up @@ -206,5 +206,5 @@ func TestFileWriterTotalBytesBuffered(t *testing.T) {

// Verify total bytes & compressed bytes are correct
assert.Equal(t, int64(596), writer.TotalCompressedBytes())
assert.Equal(t, int64(1308), writer.TotalBytesWritten())
assert.Equal(t, int64(1306), writer.TotalBytesWritten())
}
1 change: 1 addition & 0 deletions parquet/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ func (t *toThriftVisitor) VisitPost(Node) {}
func ToThrift(schema *GroupNode) []*format.SchemaElement {
t := &toThriftVisitor{make([]*format.SchemaElement, 0)}
schema.Visit(t)
t.elements[0].RepetitionType = nil
return t.elements
}

Expand Down
21 changes: 20 additions & 1 deletion parquet/schema/schema_flatten_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ func (s *SchemaFlattenSuite) TestDecimalMetadata() {

func (s *SchemaFlattenSuite) TestNestedExample() {
elements := make([]*format.SchemaElement, 0)
root := NewGroup(s.name, format.FieldRepetitionType_REPEATED, 2 /* numChildren */, 0 /* fieldID */)
root.RepetitionType = nil
elements = append(elements,
NewGroup(s.name, format.FieldRepetitionType_REPEATED, 2 /* numChildren */, 0 /* fieldID */),
root,
NewPrimitive("a" /* name */, format.FieldRepetitionType_REQUIRED, format.Type_INT32, 1 /* fieldID */),
NewGroup("bag" /* name */, format.FieldRepetitionType_OPTIONAL, 1 /* numChildren */, 2 /* fieldID */))

Expand All @@ -120,6 +122,23 @@ func TestSchemaFlatten(t *testing.T) {
suite.Run(t, new(SchemaFlattenSuite))
}

func TestToThriftRootRepetitionStripped(t *testing.T) {
for _, rep := range []parquet.Repetition{
parquet.Repetitions.Repeated,
parquet.Repetitions.Required,
parquet.Repetitions.Optional,
} {
group := MustGroup(NewGroupNode("schema", rep, FieldList{
NewInt32Node("a", parquet.Repetitions.Required, -1),
}, -1))
elements := ToThrift(group)
assert.False(t, elements[0].IsSetRepetitionType(),
"root element should not have repetition_type set (was %v)", rep)
assert.True(t, elements[1].IsSetRepetitionType(),
"non-root element must have repetition_type set")
}
}

func TestInvalidConvertedTypeInDeserialize(t *testing.T) {
n := MustPrimitive(NewPrimitiveNodeLogical("string" /* name */, parquet.Repetitions.Required, StringLogicalType{},
parquet.Types.ByteArray, -1 /* type len */, -1 /* fieldID */))
Expand Down