[Go] Support for casting to extension types
- Dominant language
- Assembly
- Stars
- 404
- Forks
- 145
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 87
Description
### Describe the enhancement requested
Right now it seems like there is support for casting from extension types to their underlying storage types, but not vice versa.
The `cast_test.go` tests include these cases, for example:
```
canCast(types.NewSmallintType(), []arrow.DataType{arrow.PrimitiveTypes.Int16})
canCast(types.NewSmallintType(), numericTypes) // any cast which is valid for storage is supported
canCast(arrow.Null, []arrow.DataType{types.NewSmallintType()})
```
But adding this case, from the storage type to the extension type, fails:
```
canCast(arrow.PrimitiveTypes.Int16, []arrow.DataType{types.NewSmallintType()}) // casting from storage type to extension is supported
```
```
=== RUN TestCasts/TestCanCast
cast_test.go:335:
Error Trace: /Users/hermanschaaf/code/cloudquery/arrow/go/arrow/compute/cast_test.go:335
/Users/hermanschaaf/code/cloudquery/arrow/go/arrow/compute/cast_test.go:341
/Users/hermanschaaf/code/cloudquery/arrow/go/arrow/compute/cast_test.go:401
Error: Not equal:
expected: true
actual : false
Test: TestCasts/TestCanCast
Messages: CanCast from: int16, to: extension_type, expected: true
```
It seems like this should be possible, as long as the type being cast from matches the storage type. Is there another way to do this that I might be missing?
### Component(s)
Go
Contributor guide
Research direction
Start with arrow/compute/cast_test.go, especially TestCasts/TestCanCast and the existing extension-type cases. Trace the CanCast path for a storage type and its matching extension type, then add coverage for the requested direction and confirm the test expects true and passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- data
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100