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

Method test_write_with_options

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

Source from the content-addressed store, hash-verified

147 end
148
149 def test_write_with_options
150 message_data = ["Start", nil, "Reboot"]
151 count_data = [2, 9, 5]
152 message_field = Arrow::Field.new("message", Arrow::StringDataType.new)
153 count_field = Arrow::Field.new("count", Arrow::Int64DataType.new)
154 schema = Arrow::Schema.new([message_field, count_field])
155
156 options = Arrow::CSVWriteOptions.new
157 options.include_header = false
158 options.delimiter = ";".ord
159 options.quoting_style = Arrow::CSVQuotingStyle::NONE
160 options.null_string = "NULL"
161
162 buffer = Arrow::ResizableBuffer.new(0)
163 output = Arrow::BufferOutputStream.new(buffer)
164 begin
165 csv_writer = Arrow::CSVWriter.new(output, schema, options)
166 begin
167 record_batch = Arrow::RecordBatch.new(schema,
168 message_data.size,
169 [
170 build_string_array(message_data),
171 build_int64_array(count_data),
172 ])
173 csv_writer.write_record_batch(record_batch)
174 ensure
175 csv_writer.close
176 end
177 ensure
178 output.close
179 end
180
181 csv_output = buffer.data.to_s
182 expected = <<~CSV
183 Start;2
184 NULL;9
185 Reboot;5
186 CSV
187 assert_equal(expected, csv_output)
188 end
189 end
190end

Callers

nothing calls this directly

Calls 7

write_record_batchMethod · 0.80
newMethod · 0.45
delimiterMethod · 0.45
sizeMethod · 0.45
closeMethod · 0.45
to_sMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected