[Go] enhancement request to expose AnyValue() on Scalar
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 38/100
Research direction
Start at the Scalar interface and trace scalar.GetScalar and the existing scalar implementations to understand how values are represented. Check whether each scalar type can expose its underlying typed value without conversion, then verify that callers can build []any values for serialization without a type switch.
Written by the indexing model from the issue text.
Description
Describe the enhancement requested
I wanted to gauge interest in a method on the Scalar interface to expose the value via any/interface{} like:
type Scalar interface {
…
AnyValue() any
…
}
Usage: This would greatly help scenarios where the user is intentionally serializing to another format (e.g. JSON) and would like to incur memory overhead.
For example, creating an array of anys for serialization. I know that String() can also be used for this, but it doesn't preserve the type.
I'm thinking that this also allows the user to recover the type via casting subsequently. However, it allows for handling the scalar value without casting of the Scalar value first.
Example usage:
func RecordsToAnyArr(recs []arrow.Record) (rec [][]any, err error) {
rows := make([][]any, 0)
for _, rec := range recs {
for r := 0; r < int(rec.NumRows()); r++ {
row := make([]any, rec.NumCols())
for c := 0; c < int(rec.NumCols()); c++ {
col := rec.Column(c)
s, err := scalar.GetScalar(col, r)
if err != nil {
return err
}
row[c] = s.AnyValue()
rows = append(rows, row)
}
}
}
Today, this would large switch case statement to achieve this.
Let me know if I'm missing something.
Component(s)
Go
Related to apache/arrow#10972
- Dominant language
- Assembly
- Stars
- 406
- Forks
- 146
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 93
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/arrow-go
-
Type: enhancement
Difficulty 5/5 Over a week Newbie friendliness 30/100
-
Type: usage
Difficulty 4/5 3-5 days Newbie friendliness 38/100
-
Difficulty 3/5 1-2 days Newbie friendliness 90/100
-
good-first-issue Type: enhancement Type: usage
Difficulty 4/5 3-5 days Newbie friendliness 52/100
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
removeToken
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
cowprotocol/token-lists#1514 · 2 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
anomalyco/models.dev#7670 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
cisagov/cyhy-reports#149 · 3 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100