zeroshade commented on code in PR #35303:
URL: https://github.com/apache/arrow/pull/35303#discussion_r1175693087
##########
go/parquet/pqarrow/schema.go:
##########
@@ -388,7 +388,7 @@ func fieldToNode(name string, field arrow.Field, props
*parquet.WriterProperties
}
return schema.MapOf(field.Name, keyNode, valueNode,
repFromNullable(field.Nullable), -1)
default:
- return nil, xerrors.New("not implemented yet")
+ return nil, xerrors.Errorf("support for %v not implemented
yet", field.Type.ID())
Review Comment:
let's use `fmt.Errorf("%w: support for %s", arrow.ErrNotImplemented,
field.Type.ID())`
##########
go/parquet/pqarrow/schema_test.go:
##########
@@ -410,3 +411,33 @@ func TestListStructBackwardCompatible(t *testing.T) {
assert.NoError(t, err)
assert.True(t, arrowSchema.Equal(arrsc))
}
+
+// TestUnsupportedTypes tests the error message for unsupported types. This
test should be updated
+// when support for these types is added.
+func TestUnsupportedTypes(t *testing.T) {
+ unsupportedTypes := []struct {
+ typ arrow.DataType
+ }{
+ // Non-exhaustive list of unsupported types
+ {typ: &arrow.Float16Type{}},
+ {typ: &arrow.DurationType{}},
+ {typ: &arrow.DayTimeIntervalType{}},
+ {typ: &arrow.MonthIntervalType{}},
+ {typ: &arrow.MonthDayNanoIntervalType{}},
+ {typ: &arrow.DenseUnionType{}},
+ {typ: &arrow.SparseUnionType{}},
+ }
+ for _, tc := range unsupportedTypes {
+ t.Run(tc.typ.ID().String(), func(t *testing.T) {
+ arrowFields := make([]arrow.Field, 0)
+ arrowFields = append(arrowFields, arrow.Field{Name:
"unsupported", Type: tc.typ, Nullable: true})
+ arrowSchema := arrow.NewSchema(arrowFields, nil)
+ _, err := pqarrow.ToParquet(arrowSchema, nil,
pqarrow.NewArrowWriterProperties())
+ assert.Error(t, err)
+ if err != nil {
+ wantMsg := fmt.Sprintf("support for %s not
implemented yet", tc.typ.ID())
+ assert.Equal(t, wantMsg, err.Error())
+ }
Review Comment:
Let's do
```go
assert.ErrorIs(t, err, arrow.ErrNotImplemented)
assert.ErrorContains(t, err, "support for " + tc.typ.ID().String())
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]