Skip to content

[Go] Support for casting to extension types #61

@hermanschaaf

Description

@hermanschaaf

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<storage=int16>, 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions