Skip to content
Merged
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: 3 additions & 1 deletion parquet/pqarrow/encode_dictionary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,9 @@ func TestArrowWriteNestedSubfieldDictionary(t *testing.T) {
dictValues := array.NewDictionaryArray(dictType, indices, dict)
defer dictValues.Release()

data := array.NewData(arrow.ListOf(dictType), 3, []*memory.Buffer{nil, offsets.Data().Buffers()[1]},
data := array.NewData(arrow.ListOfField(arrow.Field{
Name: "element", Type: dictType, Nullable: true,
Metadata: arrow.NewMetadata([]string{"PARQUET:field_id"}, []string{"-1"})}), 3, []*memory.Buffer{nil, offsets.Data().Buffers()[1]},
[]arrow.ArrayData{dictValues.Data()}, 0, 0)
defer data.Release()
values := array.NewListData(data)
Expand Down
6 changes: 3 additions & 3 deletions parquet/pqarrow/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -1011,19 +1011,19 @@ func getNestedFactory(origin, inferred arrow.DataType) func(fieldList []arrow.Fi
switch origin.ID() {
case arrow.LIST:
return func(list []arrow.Field) arrow.DataType {
return arrow.ListOf(list[0].Type)
return arrow.ListOfField(list[0])
}
case arrow.FIXED_SIZE_LIST:
sz := origin.(*arrow.FixedSizeListType).Len()
return func(list []arrow.Field) arrow.DataType {
return arrow.FixedSizeListOf(sz, list[0].Type)
return arrow.FixedSizeListOfField(sz, list[0])
}
}
case arrow.MAP:
if origin.ID() == arrow.MAP {
return func(list []arrow.Field) arrow.DataType {
valType := list[0].Type.(*arrow.StructType)
return arrow.MapOf(valType.Field(0).Type, valType.Field(1).Type)
return arrow.MapOfFields(valType.Field(0), valType.Field(1))
}
}
}
Expand Down
30 changes: 30 additions & 0 deletions parquet/pqarrow/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,36 @@ func TestProperListElementNullability(t *testing.T) {
assert.True(t, arrSchema.Equal(outSchema), "expected: %s, got: %s", arrSchema, outSchema)
}

func TestFieldNestedPropagate(t *testing.T) {
arrSchema := arrow.NewSchema([]arrow.Field{
{Name: "transformations", Type: arrow.ListOfField(
arrow.Field{
Name: "element",
Type: arrow.StructOf(
arrow.Field{Name: "destination", Type: arrow.BinaryTypes.String,
Metadata: arrow.NewMetadata([]string{"PARQUET:field_id"}, []string{"6"})},
arrow.Field{Name: "transform_type", Type: arrow.BinaryTypes.String,
Metadata: arrow.NewMetadata([]string{"PARQUET:field_id"}, []string{"7"})},
arrow.Field{Name: "transform_value", Type: arrow.BinaryTypes.String,
Metadata: arrow.NewMetadata([]string{"PARQUET:field_id"}, []string{"8"})},
arrow.Field{Name: "source_cols", Type: arrow.ListOfField(
arrow.Field{Name: "element", Type: arrow.BinaryTypes.String, Metadata: arrow.NewMetadata([]string{"PARQUET:field_id"}, []string{"10"})}),
Metadata: arrow.NewMetadata([]string{"PARQUET:field_id"}, []string{"9"})},
),
Metadata: arrow.NewMetadata([]string{"PARQUET:field_id"}, []string{"5"}),
},
), Metadata: arrow.NewMetadata([]string{"PARQUET:field_id"}, []string{"4"})},
}, nil)

pqSchema, err := pqarrow.ToParquet(arrSchema, nil, pqarrow.DefaultWriterProps())
require.NoError(t, err)

result, err := pqarrow.FromParquet(pqSchema, nil, metadata.KeyValueMetadata{})
require.NoError(t, err)

assert.True(t, arrSchema.Equal(result), "expected: %s, got: %s", arrSchema, result)
}

func TestConvertSchemaParquetVariant(t *testing.T) {
// unshredded variant:
// optional group variant_col {
Expand Down
Loading