diff --git a/c_glib/arrow-glib/reader.cpp b/c_glib/arrow-glib/reader.cpp index 8e84eb58b13..8d88fc1e4b2 100644 --- a/c_glib/arrow-glib/reader.cpp +++ b/c_glib/arrow-glib/reader.cpp @@ -393,7 +393,7 @@ GArrowTableBatchReader * garrow_table_batch_reader_new(GArrowTable *table) { auto arrow_table = garrow_table_get_raw(table); - auto arrow_table_batch_reader = std::make_shared(*arrow_table); + auto arrow_table_batch_reader = std::make_shared(arrow_table); return garrow_table_batch_reader_new_raw(&arrow_table_batch_reader, table); } diff --git a/ruby/red-arrow/test/test-record-batch-reader.rb b/ruby/red-arrow/test/test-record-batch-reader.rb index 1becdf5b63b..3a94290d535 100644 --- a/ruby/red-arrow/test/test-record-batch-reader.rb +++ b/ruby/red-arrow/test/test-record-batch-reader.rb @@ -43,4 +43,14 @@ class TestRecordBatchReader < Test::Unit::TestCase reader.read_all) end end + + test("exported TableBatchReader keeps its table alive") do + expected = Arrow::Table.new("count" => [1, 2, 3]) + stream = + Arrow::TableBatchReader.new(Arrow::Table.new("count" => [1, 2, 3])).export + GC.start + + reader = Arrow::RecordBatchReader.import(stream) + assert_equal(expected, reader.read_all) + end end