hcrosse opened a new issue, #1463:
URL: https://github.com/apache/arrow-go/issues/1463

   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   Passing a null dictionary scalar to `is_null` crashes the process instead of 
returning `true`. The panic happens in an executor goroutine, so the caller 
cannot recover it.
   
   I reproduced this on v18.8.0 and on main at `c620eaa3`, on macOS with Go 
1.27.3.
   
   **Reproduction**
   
   Save this as `main.go` in a module that requires 
`github.com/apache/arrow-go/v18 v18.8.0`, or in a new subdirectory of an 
arrow-go checkout at `c620eaa363c1b68ed93a810da7a8d46bd436f122`, then run `go 
run .` from that directory:
   
   ```go
   package main
   
   import (
        "context"
        "fmt"
   
        "github.com/apache/arrow-go/v18/arrow"
        "github.com/apache/arrow-go/v18/arrow/compute"
        "github.com/apache/arrow-go/v18/arrow/scalar"
   )
   
   func main() {
        dt := &arrow.DictionaryType{IndexType: arrow.PrimitiveTypes.Int8, 
ValueType: arrow.BinaryTypes.String}
        s := scalar.MakeNullScalar(dt)
   
        out, err := compute.CallFunction(context.Background(), "is_null", nil, 
compute.NewDatum(s))
        if err != nil {
                panic(err)
        }
        defer out.Release()
        fmt.Println(out)
   }
   ```
   
   It exits with:
   
   ```text
   panic: runtime error: invalid memory address or nil pointer dereference
   ```
   
   **Expected behavior**
   
   `is_null` should return `true` without panicking. In pyarrow `26.0.0`, the 
equivalent null dictionary scalar has an empty string dictionary, passes full 
validation, and returns `True` from `is_null`.
   
   **Cause**
   
   `NewNullDictScalar`, which `MakeNullScalar` calls for dictionary types, 
leaves `Value.Dict` nil:
   
   
https://github.com/apache/arrow-go/blob/c620eaa363c1b68ed93a810da7a8d46bd436f122/arrow/scalar/nested.go#L352-L357
   
   During promotion of the scalar to an array, `exec.ArraySpan.FillFromScalar` 
dereferences that dictionary:
   
   
https://github.com/apache/arrow-go/blob/c620eaa363c1b68ed93a810da7a8d46bd436f122/arrow/compute/exec/span.go#L300-L306
   
   An empty dictionary of the value type avoids this panic, as in Arrow C++'s 
[`DictionaryScalar(type)` 
constructor](https://github.com/apache/arrow/blob/0ab78e2df489055b71a7d26a666a52823f87f01c/cpp/src/arrow/scalar.cc#L768-L773).
   
   I have a patch with tests and can open a PR.
   
   ### Component(s)
   
   Other
   


-- 
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]

Reply via email to