Skip to content

Add more support for ScalarValue::Float16 where Float32 and Float64 are supported #11083

@LorrensP-2158466

Description

@LorrensP-2158466

Is your feature request related to a problem or challenge?

When fixing #11076, I noticed that not every method in ScalarValue supports a ScalarValue::Float16 while supporting Float32 and Float64:
For example in (from #11076):

pub fn arithmetic_negate(&self) -> Result<Self> {

We see that F32 and F64 are supported, but not F16
ScalarValue::Float64(Some(v)) => Ok(ScalarValue::Float64(Some(-v))),
ScalarValue::Float32(Some(v)) => Ok(ScalarValue::Float32(Some(-v))),

Describe the solution you'd like

  • Every method that supports Float32 and Float64 should support Float16 (including constructors)
  • implement From<f16> for ScalarValue
  • Add tests
  • More to do?

half::f16 supports many of these operations, so I think it is doable. ArrowNativeType and ArrowNativeTypeOp are also implemented so we can use a lot of functions from that trait.

Describe alternatives you've considered

Maybe show in docs why Float16 is not supported in some cases?

Additional context

Can this be a "good first issue" ?
No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions