MCPcopy Create free account
hub / github.com/apache/arrow / test_write_table

Method test_write_table

c_glib/test/test-csv-writer.rb:59–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57 end
58
59 def test_write_table
60 message_data = ["Start", "Shutdown", "Reboot"]
61 count_data = [2, 9, 5]
62 message_field = Arrow::Field.new("message", Arrow::StringDataType.new)
63 count_field = Arrow::Field.new("count", Arrow::Int64DataType.new)
64 schema = Arrow::Schema.new([message_field, count_field])
65
66 buffer = Arrow::ResizableBuffer.new(0)
67 output = Arrow::BufferOutputStream.new(buffer)
68 begin
69 csv_writer = Arrow::CSVWriter.new(output, schema)
70 begin
71 table = Arrow::Table.new(schema,
72 [
73 build_string_array(message_data),
74 build_int64_array(count_data),
75 ])
76 csv_writer.write_table(table)
77 ensure
78 csv_writer.close
79 assert do
80 csv_writer.closed?
81 end
82 end
83 ensure
84 output.close
85 end
86
87 csv_output = buffer.data.to_s
88 expected = <<~CSV
89 "message","count"
90 "Start",2
91 "Shutdown",9
92 "Reboot",5
93 CSV
94 assert_equal(expected, csv_output)
95 end
96
97
98 sub_test_case("options") do

Callers

nothing calls this directly

Calls 5

newMethod · 0.45
write_tableMethod · 0.45
closeMethod · 0.45
to_sMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected