zeroshade commented on code in PR #928:
URL: https://github.com/apache/arrow-go/pull/928#discussion_r3572941531
##########
arrow/scalar/scalar.go:
##########
@@ -1063,8 +1067,29 @@ func Hash(seed maphash.Seed, s Scalar) uint64 {
case TemporalScalar:
return valueHash(s.value())
case ListScalar:
- array.Hash(&h, s.GetList().Data())
- hash()
+ list := s.GetList()
+ hashUint64(uint64(list.Len()))
+ for i := 0; i < list.Len(); i++ {
+ // Include the logical position in the same chunk as
the element so
+ // that list order affects the aggregate hash.
+ binary.Write(&h, endian.Native, uint64(i))
+ if list.IsNull(i) {
+ h.Write([]byte{0})
+ hash()
+ continue
+ }
+
+ value, err := GetScalar(list, i)
+ if err != nil {
+ panic(err)
Review Comment:
`panic(err)` here turns a valid list into a crash. `NewListScalar` accepts
any `arrow.Array` as its child values, and several types are hashable via
`array.Hash` but unsupported by `GetScalar` — e.g. `string_view`,
`binary_view`, `decimal32`, `decimal64`, `list_view`, `large_list_view`. Those
hashed fine on the previous data-based path, so this is a regression. Please
avoid making list hashing depend on `GetScalar` coverage (or add `GetScalar`
support for every array type that can appear as list values before this is
allowed to panic).
--
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]