zeroshade commented on code in PR #904:
URL: https://github.com/apache/arrow-go/pull/904#discussion_r3554123684
##########
arrow/array/array.go:
##########
@@ -117,7 +117,11 @@ func invalidDataType(data arrow.ArrayData) arrow.Array {
// MakeFromData constructs a strongly-typed array instance from generic Data.
func MakeFromData(data arrow.ArrayData) arrow.Array {
- return makeArrayFn[byte(data.DataType().ID()&0x3f)](data)
+ id := int(data.DataType().ID())
+ if id < 0 || id >= len(makeArrayFn) || makeArrayFn[id] == nil {
+ invalidDataType(data)
Review Comment:
Nit: prefer `return invalidDataType(data)` here. As written it relies on
`invalidDataType` panicking as a side effect; returning it is clearer and stays
correct even if that helper is ever changed to return a sentinel/typed error
instead of panicking (otherwise execution would fall through to
`makeArrayFn[id](data)` with an invalid `id`).
--
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]