diff --git a/c_glib/arrow-glib/reader.cpp b/c_glib/arrow-glib/reader.cpp index 8e84eb58b13a..8d88fc1e4b23 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/c_glib/test/test-table-batch-reader.rb b/c_glib/test/test-table-batch-reader.rb index 3b00b9067acd..b52d310b6131 100644 --- a/c_glib/test/test-table-batch-reader.rb +++ b/c_glib/test/test-table-batch-reader.rb @@ -17,6 +17,7 @@ class TestTableBatchReader < Test::Unit::TestCase include Helper::Buildable + include Helper::Omittable def test_empty table = build_table("visible" => build_boolean_array([])) @@ -51,4 +52,15 @@ def test_max_chunk_size reader.read_next) assert_nil(reader.read_next) end + + def test_export_gc + require_gi_bindings(3, 4, 8) + array = build_int32_array([1, 2, 3]) + table = build_table("number" => array) + c_abi_array_stream = Arrow::TableBatchReader.new(table).export + table = nil + GC.start + assert_equal(build_table("number" => array), + Arrow::RecordBatchReader.import(c_abi_array_stream).read_all) + end end