Skip to content

Commit

Permalink
apacheGH-37562: [Ruby] Add support for table.each_raw_record.to_a (ap…
Browse files Browse the repository at this point in the history
…ache#37600)

### Rationale for this change

This change aligns the behavior of `each_raw_record` with standard Ruby practices by returning an enumerator when no block is provided

### What changes are included in this PR?

- Made `Arrow::Table#each_raw_record` and `Arrow::RecordBatch#each_raw_record` return Enumerator when it was called without block.
- Added related tests
- Resolved warnings related to duplicate test classes which were caused by apache#37137

### Are these changes tested?

Yes.

### Are there any user-facing changes?

No

* Closes: apache#37562

Authored-by: otegami <a.s.takuya1026@gmail.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
  • Loading branch information
otegami authored Sep 11, 2023
1 parent c0c56e8 commit e56726c
Show file tree
Hide file tree
Showing 10 changed files with 247 additions and 1,190 deletions.
4 changes: 3 additions & 1 deletion ruby/red-arrow/ext/arrow/raw-records.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,10 @@ namespace red_arrow {
}

VALUE
record_batch_each_raw_record(VALUE rb_record_batch){
record_batch_each_raw_record(VALUE rb_record_batch) {
auto garrow_record_batch = GARROW_RECORD_BATCH(RVAL2GOBJ(rb_record_batch));
auto record_batch = garrow_record_batch_get_raw(garrow_record_batch).get();
RETURN_SIZED_ENUMERATOR(rb_record_batch, 0, nullptr, record_batch->num_rows());

try {
RawRecordsProducer producer;
Expand All @@ -323,6 +324,7 @@ namespace red_arrow {
table_each_raw_record(VALUE rb_table) {
auto garrow_table = GARROW_TABLE(RVAL2GOBJ(rb_table));
auto table = garrow_table_get_raw(garrow_table).get();
RETURN_SIZED_ENUMERATOR(rb_table, 0, nullptr, table->num_rows());

try {
RawRecordsProducer producer;
Expand Down
Loading

0 comments on commit e56726c

Please sign in to comment.