You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "fpacanowski (via GitHub)" <gi...@apache.org> on 2024/12/29 09:32:26 UTC
[I] [Ruby] Provide an equivalent of Pyarrow's `.to_pylist` [arrow]
fpacanowski opened a new issue, #45122:
URL: https://github.com/apache/arrow/issues/45122
### Describe the enhancement requested
In certain use cases it's quite useful to convert a `RecordBatch` or a `Table` to an array of hashes, e.g. when using Parquet for data exchange. Pyarrow provides this functionality as [to_pylist](https://arrow.apache.org/docs/python/generated/pyarrow.Table.html#pyarrow.Table.to_pylist) function.
Basically I'd love to see an inverse of `Arrow::RecordBatchBuilder.build`.
```ruby
rb = Arrow::RecordBatchBuilder.build(schema, data)
assert rb.to_pylist == data
```
Additionally it would be great if it correctly handled struct and list data type, for example:
```ruby
schema = Arrow::Schema.new([
Arrow::Field.new("c1", :int32),
Arrow::Field.new("c2",
Arrow::StructDataType.new([
Arrow::Field.new("c3", :int32),
Arrow::Field.new("c4",
Arrow::StructDataType.new([
Arrow::Field.new("c5", :int32),
Arrow::Field.new("c6", Arrow::ListDataType.new(:int32)),
])
)
])
)
])
data = [
{c1: 1, c2: {c3: 3, c4: {c5: 5, c6: [6, 7]}}},
{c1: 11, c2: {c3: 13, c4: {c5: 15, c6: [16, 17]}}},
]
rb = Arrow::RecordBatchBuilder.build(schema, data)
assert rb.to_pylist == data
```
(Obviously the method wouldn't be named `to_pylist`.)
### Component(s)
Ruby
--
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: issues-unsubscribe@arrow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Ruby] Provide an equivalent of Pyarrow's `.to_pylist` [arrow]
Posted by "kou (via GitHub)" <gi...@apache.org>.
kou commented on issue #45122:
URL: https://github.com/apache/arrow/issues/45122#issuecomment-2566177335
We have `Arrow::RecordBatch#raw_records`/`Arrow::Table#raw_records` and `#each_raw_record`.
But they don't add keys: `[1, {"c3" => 3, "c4" => {"c5" => 5, "c6" => [6, 7]}}]`
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Ruby] Provide an equivalent of Pyarrow's `.to_pylist` [arrow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #45122:
URL: https://github.com/apache/arrow/issues/45122#issuecomment-4004353970
This issue has been marked as stale because it has had no activity in the past 365 days. Please remove the stale label or comment below, or this issue will be closed in 14 days. If this improvement is still desired but has no current owner, please add the 'Status: needs champion' label.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org