red-arrow 8.0.0 → 24.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +15 -7
  3. data/ext/arrow/arrow.cpp +67 -0
  4. data/ext/arrow/converters.cpp +10 -0
  5. data/ext/arrow/converters.hpp +310 -46
  6. data/ext/arrow/extconf.rb +41 -22
  7. data/ext/arrow/raw-records.cpp +165 -2
  8. data/ext/arrow/red-arrow.hpp +2 -0
  9. data/ext/arrow/values.cpp +6 -2
  10. data/lib/arrow/array-builder.rb +89 -14
  11. data/{test/test-time32-data-type.rb → lib/arrow/array-computable.rb} +24 -16
  12. data/{test/test-buffer.rb → lib/arrow/array-statistics.rb} +19 -24
  13. data/lib/arrow/array.rb +40 -4
  14. data/lib/arrow/chunked-array.rb +56 -1
  15. data/lib/arrow/column-containable.rb +9 -0
  16. data/lib/arrow/column.rb +49 -4
  17. data/{test/test-tensor.rb → lib/arrow/csv-write-options.rb} +28 -31
  18. data/lib/arrow/data-type.rb +17 -3
  19. data/lib/arrow/decimal128-array-builder.rb +16 -6
  20. data/lib/arrow/decimal128.rb +14 -0
  21. data/lib/arrow/decimal256-array-builder.rb +16 -6
  22. data/lib/arrow/decimal256.rb +14 -0
  23. data/{test/test-float-scalar.rb → lib/arrow/dense-union-array-builder.rb} +27 -24
  24. data/{test/test-boolean-scalar.rb → lib/arrow/dense-union-array.rb} +7 -7
  25. data/lib/arrow/duration-array-builder.rb +27 -0
  26. data/lib/arrow/duration-array.rb +24 -0
  27. data/lib/arrow/duration-data-type.rb +32 -0
  28. data/lib/arrow/expression.rb +6 -2
  29. data/lib/arrow/field-containable.rb +1 -1
  30. data/lib/arrow/field.rb +44 -3
  31. data/lib/arrow/fixed-size-list-array-builder.rb +29 -0
  32. data/lib/arrow/fixed-size-list-data-type.rb +118 -0
  33. data/lib/arrow/function.rb +0 -1
  34. data/lib/arrow/half-float-array-builder.rb +32 -0
  35. data/lib/arrow/half-float-array.rb +24 -0
  36. data/lib/arrow/half-float.rb +118 -0
  37. data/{test/helper/fixture.rb → lib/arrow/input-referable.rb} +7 -6
  38. data/lib/arrow/jruby/array-builder.rb +114 -0
  39. data/lib/arrow/jruby/array.rb +109 -0
  40. data/lib/arrow/jruby/chunked-array.rb +36 -0
  41. data/lib/arrow/jruby/compression-type.rb +26 -0
  42. data/lib/arrow/jruby/csv-read-options.rb +32 -0
  43. data/{test/test-map-data-type.rb → lib/arrow/jruby/data-type.rb} +24 -12
  44. data/lib/arrow/jruby/decimal128.rb +28 -0
  45. data/lib/arrow/jruby/decimal256.rb +28 -0
  46. data/{test/fixture/float-integer.csv → lib/arrow/jruby/error.rb} +7 -4
  47. data/lib/arrow/jruby/file-system.rb +24 -0
  48. data/{test/test-null-array.rb → lib/arrow/jruby/function.rb} +5 -4
  49. data/lib/arrow/jruby/record-batch-iterator.rb +24 -0
  50. data/{test/fixture/null-with-double-quote.csv → lib/arrow/jruby/record-batch.rb} +8 -4
  51. data/{test/fixture/integer-float.csv → lib/arrow/jruby/sort-key.rb} +8 -4
  52. data/lib/arrow/jruby/sort-options.rb +24 -0
  53. data/lib/arrow/jruby/stream-listener-raw.rb +25 -0
  54. data/{test/test-rolling-window.rb → lib/arrow/jruby/table.rb} +19 -19
  55. data/lib/arrow/jruby/writable.rb +24 -0
  56. data/lib/arrow/jruby.rb +52 -0
  57. data/{test/test-date32-array.rb → lib/arrow/large-list-array-builder.rb} +10 -5
  58. data/lib/arrow/large-list-data-type.rb +83 -0
  59. data/lib/arrow/libraries.rb +140 -0
  60. data/lib/arrow/list-array-builder.rb +1 -68
  61. data/lib/arrow/list-data-type.rb +3 -38
  62. data/{test/test-dictionary-array.rb → lib/arrow/list-field-resolvable.rb} +26 -17
  63. data/lib/arrow/list-slice-options.rb +76 -0
  64. data/lib/arrow/list-values-appendable.rb +88 -0
  65. data/lib/arrow/loader.rb +15 -96
  66. data/{test/test-decimal128-array.rb → lib/arrow/make-struct-options.rb} +18 -18
  67. data/lib/arrow/raw-table-converter.rb +10 -3
  68. data/lib/arrow/raw-tensor-converter.rb +89 -0
  69. data/lib/arrow/record-batch-file-reader.rb +2 -0
  70. data/lib/arrow/record-batch-stream-reader.rb +2 -0
  71. data/lib/arrow/record-batch.rb +6 -2
  72. data/{test/fixture/null-without-double-quote.csv → lib/arrow/ruby.rb} +5 -4
  73. data/lib/arrow/scalar.rb +67 -0
  74. data/lib/arrow/slicer.rb +61 -0
  75. data/lib/arrow/sort-key.rb +3 -3
  76. data/lib/arrow/sparse-union-array-builder.rb +56 -0
  77. data/lib/arrow/sparse-union-array.rb +26 -0
  78. data/lib/arrow/stream-decoder.rb +29 -0
  79. data/{test/test-decimal256-data-type.rb → lib/arrow/stream-listener.rb} +25 -9
  80. data/lib/arrow/string-array-builder.rb +30 -0
  81. data/lib/arrow/struct-array-builder.rb +0 -5
  82. data/lib/arrow/table-formatter.rb +38 -8
  83. data/lib/arrow/table-list-formatter.rb +3 -3
  84. data/lib/arrow/table-loader.rb +11 -5
  85. data/lib/arrow/table-saver.rb +4 -3
  86. data/lib/arrow/table-table-formatter.rb +7 -0
  87. data/lib/arrow/table.rb +180 -33
  88. data/lib/arrow/tensor.rb +144 -0
  89. data/lib/arrow/time-unit.rb +31 -0
  90. data/lib/arrow/time32-array-builder.rb +2 -14
  91. data/lib/arrow/time32-data-type.rb +9 -38
  92. data/lib/arrow/time64-array-builder.rb +2 -14
  93. data/lib/arrow/time64-data-type.rb +9 -38
  94. data/lib/arrow/timestamp-array-builder.rb +3 -15
  95. data/lib/arrow/timestamp-data-type.rb +9 -34
  96. data/{test/test-date64-array.rb → lib/arrow/timestamp-parser.rb} +14 -6
  97. data/lib/arrow/union-array-builder.rb +59 -0
  98. data/lib/arrow/union-array.rb +26 -0
  99. data/lib/arrow/version.rb +1 -1
  100. data/lib/arrow.rb +2 -7
  101. data/red-arrow.gemspec +74 -11
  102. metadata +85 -210
  103. data/test/fixture/TestOrcFile.test1.orc +0 -0
  104. data/test/fixture/with-header-float.csv +0 -20
  105. data/test/fixture/with-header.csv +0 -20
  106. data/test/fixture/without-header-float.csv +0 -19
  107. data/test/fixture/without-header.csv +0 -19
  108. data/test/helper/omittable.rb +0 -36
  109. data/test/helper.rb +0 -30
  110. data/test/raw-records/test-basic-arrays.rb +0 -395
  111. data/test/raw-records/test-dense-union-array.rb +0 -521
  112. data/test/raw-records/test-list-array.rb +0 -610
  113. data/test/raw-records/test-map-array.rb +0 -478
  114. data/test/raw-records/test-multiple-columns.rb +0 -65
  115. data/test/raw-records/test-sparse-union-array.rb +0 -511
  116. data/test/raw-records/test-struct-array.rb +0 -515
  117. data/test/raw-records/test-table.rb +0 -47
  118. data/test/run-test.rb +0 -71
  119. data/test/test-array-builder.rb +0 -136
  120. data/test/test-array.rb +0 -325
  121. data/test/test-bigdecimal.rb +0 -40
  122. data/test/test-binary-dictionary-array-builder.rb +0 -103
  123. data/test/test-chunked-array.rb +0 -183
  124. data/test/test-column.rb +0 -92
  125. data/test/test-csv-loader.rb +0 -250
  126. data/test/test-data-type.rb +0 -83
  127. data/test/test-decimal128-array-builder.rb +0 -112
  128. data/test/test-decimal128-data-type.rb +0 -31
  129. data/test/test-decimal128.rb +0 -102
  130. data/test/test-decimal256-array-builder.rb +0 -112
  131. data/test/test-decimal256-array.rb +0 -38
  132. data/test/test-decimal256.rb +0 -102
  133. data/test/test-dense-union-data-type.rb +0 -41
  134. data/test/test-dictionary-data-type.rb +0 -40
  135. data/test/test-expression.rb +0 -40
  136. data/test/test-feather.rb +0 -49
  137. data/test/test-field.rb +0 -91
  138. data/test/test-file-output-stream.rb +0 -54
  139. data/test/test-fixed-size-binary-array-builder.rb +0 -92
  140. data/test/test-fixed-size-binary-array.rb +0 -36
  141. data/test/test-function.rb +0 -210
  142. data/test/test-group.rb +0 -180
  143. data/test/test-list-array-builder.rb +0 -79
  144. data/test/test-list-array.rb +0 -32
  145. data/test/test-list-data-type.rb +0 -69
  146. data/test/test-map-array-builder.rb +0 -110
  147. data/test/test-map-array.rb +0 -33
  148. data/test/test-memory-view.rb +0 -434
  149. data/test/test-orc.rb +0 -173
  150. data/test/test-record-batch-builder.rb +0 -125
  151. data/test/test-record-batch-file-reader.rb +0 -115
  152. data/test/test-record-batch-iterator.rb +0 -37
  153. data/test/test-record-batch-reader.rb +0 -46
  154. data/test/test-record-batch.rb +0 -182
  155. data/test/test-schema.rb +0 -134
  156. data/test/test-slicer.rb +0 -487
  157. data/test/test-sort-indices.rb +0 -40
  158. data/test/test-sort-key.rb +0 -81
  159. data/test/test-sort-options.rb +0 -58
  160. data/test/test-sparse-union-data-type.rb +0 -41
  161. data/test/test-string-dictionary-array-builder.rb +0 -103
  162. data/test/test-struct-array-builder.rb +0 -184
  163. data/test/test-struct-array.rb +0 -94
  164. data/test/test-struct-data-type.rb +0 -112
  165. data/test/test-table.rb +0 -1123
  166. data/test/test-time.rb +0 -288
  167. data/test/test-time32-array.rb +0 -81
  168. data/test/test-time64-array.rb +0 -81
  169. data/test/test-time64-data-type.rb +0 -42
  170. data/test/test-timestamp-array.rb +0 -45
  171. data/test/test-timestamp-data-type.rb +0 -42
  172. data/test/values/test-basic-arrays.rb +0 -325
  173. data/test/values/test-dense-union-array.rb +0 -509
  174. data/test/values/test-dictionary-array.rb +0 -295
  175. data/test/values/test-list-array.rb +0 -571
  176. data/test/values/test-map-array.rb +0 -466
  177. data/test/values/test-sparse-union-array.rb +0 -500
  178. data/test/values/test-struct-array.rb +0 -512
@@ -1,521 +0,0 @@
1
- # Licensed to the Apache Software Foundation (ASF) under one
2
- # or more contributor license agreements. See the NOTICE file
3
- # distributed with this work for additional information
4
- # regarding copyright ownership. The ASF licenses this file
5
- # to you under the Apache License, Version 2.0 (the
6
- # "License"); you may not use this file except in compliance
7
- # with the License. You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing,
12
- # software distributed under the License is distributed on an
13
- # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
- # KIND, either express or implied. See the License for the
15
- # specific language governing permissions and limitations
16
- # under the License.
17
-
18
- module RawRecordsDenseUnionArrayTests
19
- def build_schema(type, type_codes)
20
- field_description = {}
21
- if type.is_a?(Hash)
22
- field_description = field_description.merge(type)
23
- else
24
- field_description[:type] = type
25
- end
26
- {
27
- column: {
28
- type: :dense_union,
29
- fields: [
30
- field_description.merge(name: "0"),
31
- field_description.merge(name: "1"),
32
- ],
33
- type_codes: type_codes,
34
- },
35
- }
36
- end
37
-
38
- # TODO: Use Arrow::RecordBatch.new(build_schema(type, type_codes), records)
39
- def build_record_batch(type, records)
40
- type_codes = [0, 1]
41
- schema = Arrow::Schema.new(build_schema(type, type_codes))
42
- type_ids = []
43
- offsets = []
44
- arrays = schema.fields[0].data_type.fields.collect do |field|
45
- sub_schema = Arrow::Schema.new([field])
46
- sub_records = []
47
- records.each do |record|
48
- column = record[0]
49
- next if column.nil?
50
- next unless column.key?(field.name)
51
- sub_records << [column[field.name]]
52
- end
53
- sub_record_batch = Arrow::RecordBatch.new(sub_schema,
54
- sub_records)
55
- sub_record_batch.columns[0].data
56
- end
57
- records.each do |record|
58
- column = record[0]
59
- if column.key?("0")
60
- type_id = type_codes[0]
61
- type_ids << type_id
62
- offsets << (type_ids.count(type_id) - 1)
63
- elsif column.key?("1")
64
- type_id = type_codes[1]
65
- type_ids << type_id
66
- offsets << (type_ids.count(type_id) - 1)
67
- end
68
- end
69
- union_array = Arrow::DenseUnionArray.new(schema.fields[0].data_type,
70
- Arrow::Int8Array.new(type_ids),
71
- Arrow::Int32Array.new(offsets),
72
- arrays)
73
- schema = Arrow::Schema.new(column: union_array.value_data_type)
74
- Arrow::RecordBatch.new(schema,
75
- records.size,
76
- [union_array])
77
- end
78
-
79
- def test_null
80
- records = [
81
- [{"0" => nil}],
82
- ]
83
- target = build(:null, records)
84
- assert_equal(records, target.raw_records)
85
- end
86
-
87
- def test_boolean
88
- records = [
89
- [{"0" => true}],
90
- [{"1" => nil}],
91
- ]
92
- target = build(:boolean, records)
93
- assert_equal(records, target.raw_records)
94
- end
95
-
96
- def test_int8
97
- records = [
98
- [{"0" => -(2 ** 7)}],
99
- [{"1" => nil}],
100
- ]
101
- target = build(:int8, records)
102
- assert_equal(records, target.raw_records)
103
- end
104
-
105
- def test_uint8
106
- records = [
107
- [{"0" => (2 ** 8) - 1}],
108
- [{"1" => nil}],
109
- ]
110
- target = build(:uint8, records)
111
- assert_equal(records, target.raw_records)
112
- end
113
-
114
- def test_int16
115
- records = [
116
- [{"0" => -(2 ** 15)}],
117
- [{"1" => nil}],
118
- ]
119
- target = build(:int16, records)
120
- assert_equal(records, target.raw_records)
121
- end
122
-
123
- def test_uint16
124
- records = [
125
- [{"0" => (2 ** 16) - 1}],
126
- [{"1" => nil}],
127
- ]
128
- target = build(:uint16, records)
129
- assert_equal(records, target.raw_records)
130
- end
131
-
132
- def test_int32
133
- records = [
134
- [{"0" => -(2 ** 31)}],
135
- [{"1" => nil}],
136
- ]
137
- target = build(:int32, records)
138
- assert_equal(records, target.raw_records)
139
- end
140
-
141
- def test_uint32
142
- records = [
143
- [{"0" => (2 ** 32) - 1}],
144
- [{"1" => nil}],
145
- ]
146
- target = build(:uint32, records)
147
- assert_equal(records, target.raw_records)
148
- end
149
-
150
- def test_int64
151
- records = [
152
- [{"0" => -(2 ** 63)}],
153
- [{"1" => nil}],
154
- ]
155
- target = build(:int64, records)
156
- assert_equal(records, target.raw_records)
157
- end
158
-
159
- def test_uint64
160
- records = [
161
- [{"0" => (2 ** 64) - 1}],
162
- [{"1" => nil}],
163
- ]
164
- target = build(:uint64, records)
165
- assert_equal(records, target.raw_records)
166
- end
167
-
168
- def test_float
169
- records = [
170
- [{"0" => -1.0}],
171
- [{"1" => nil}],
172
- ]
173
- target = build(:float, records)
174
- assert_equal(records, target.raw_records)
175
- end
176
-
177
- def test_double
178
- records = [
179
- [{"0" => -1.0}],
180
- [{"1" => nil}],
181
- ]
182
- target = build(:double, records)
183
- assert_equal(records, target.raw_records)
184
- end
185
-
186
- def test_binary
187
- records = [
188
- [{"0" => "\xff".b}],
189
- [{"1" => nil}],
190
- ]
191
- target = build(:binary, records)
192
- assert_equal(records, target.raw_records)
193
- end
194
-
195
- def test_string
196
- records = [
197
- [{"0" => "Ruby"}],
198
- [{"1" => nil}],
199
- ]
200
- target = build(:string, records)
201
- assert_equal(records, target.raw_records)
202
- end
203
-
204
- def test_date32
205
- records = [
206
- [{"0" => Date.new(1960, 1, 1)}],
207
- [{"1" => nil}],
208
- ]
209
- target = build(:date32, records)
210
- assert_equal(records, target.raw_records)
211
- end
212
-
213
- def test_date64
214
- records = [
215
- [{"0" => DateTime.new(1960, 1, 1, 2, 9, 30)}],
216
- [{"1" => nil}],
217
- ]
218
- target = build(:date64, records)
219
- assert_equal(records, target.raw_records)
220
- end
221
-
222
- def test_timestamp_second
223
- records = [
224
- [{"0" => Time.parse("1960-01-01T02:09:30Z")}],
225
- [{"1" => nil}],
226
- ]
227
- target = build({
228
- type: :timestamp,
229
- unit: :second,
230
- },
231
- records)
232
- assert_equal(records, target.raw_records)
233
- end
234
-
235
- def test_timestamp_milli
236
- records = [
237
- [{"0" => Time.parse("1960-01-01T02:09:30.123Z")}],
238
- [{"1" => nil}],
239
- ]
240
- target = build({
241
- type: :timestamp,
242
- unit: :milli,
243
- },
244
- records)
245
- assert_equal(records, target.raw_records)
246
- end
247
-
248
- def test_timestamp_micro
249
- records = [
250
- [{"0" => Time.parse("1960-01-01T02:09:30.123456Z")}],
251
- [{"1" => nil}],
252
- ]
253
- target = build({
254
- type: :timestamp,
255
- unit: :micro,
256
- },
257
- records)
258
- assert_equal(records, target.raw_records)
259
- end
260
-
261
- def test_timestamp_nano
262
- records = [
263
- [{"0" => Time.parse("1960-01-01T02:09:30.123456789Z")}],
264
- [{"1" => nil}],
265
- ]
266
- target = build({
267
- type: :timestamp,
268
- unit: :nano,
269
- },
270
- records)
271
- assert_equal(records, target.raw_records)
272
- end
273
-
274
- def test_time32_second
275
- unit = Arrow::TimeUnit::SECOND
276
- records = [
277
- # 00:10:00
278
- [{"0" => Arrow::Time.new(unit, 60 * 10)}],
279
- [{"1" => nil}],
280
- ]
281
- target = build({
282
- type: :time32,
283
- unit: :second,
284
- },
285
- records)
286
- assert_equal(records, target.raw_records)
287
- end
288
-
289
- def test_time32_milli
290
- unit = Arrow::TimeUnit::MILLI
291
- records = [
292
- # 00:10:00.123
293
- [{"0" => Arrow::Time.new(unit, (60 * 10) * 1000 + 123)}],
294
- [{"1" => nil}],
295
- ]
296
- target = build({
297
- type: :time32,
298
- unit: :milli,
299
- },
300
- records)
301
- assert_equal(records, target.raw_records)
302
- end
303
-
304
- def test_time64_micro
305
- unit = Arrow::TimeUnit::MICRO
306
- records = [
307
- # 00:10:00.123456
308
- [{"0" => Arrow::Time.new(unit, (60 * 10) * 1_000_000 + 123_456)}],
309
- [{"1" => nil}],
310
- ]
311
- target = build({
312
- type: :time64,
313
- unit: :micro,
314
- },
315
- records)
316
- assert_equal(records, target.raw_records)
317
- end
318
-
319
- def test_time64_nano
320
- unit = Arrow::TimeUnit::NANO
321
- records = [
322
- # 00:10:00.123456789
323
- [{"0" => Arrow::Time.new(unit, (60 * 10) * 1_000_000_000 + 123_456_789)}],
324
- [{"1" => nil}],
325
- ]
326
- target = build({
327
- type: :time64,
328
- unit: :nano,
329
- },
330
- records)
331
- assert_equal(records, target.raw_records)
332
- end
333
-
334
- def test_decimal128
335
- records = [
336
- [{"0" => BigDecimal("92.92")}],
337
- [{"1" => nil}],
338
- ]
339
- target = build({
340
- type: :decimal128,
341
- precision: 8,
342
- scale: 2,
343
- },
344
- records)
345
- assert_equal(records, target.raw_records)
346
- end
347
-
348
- def test_decimal256
349
- records = [
350
- [{"0" => BigDecimal("92.92")}],
351
- [{"1" => nil}],
352
- ]
353
- target = build({
354
- type: :decimal256,
355
- precision: 38,
356
- scale: 2,
357
- },
358
- records)
359
- assert_equal(records, target.raw_records)
360
- end
361
-
362
- def test_month_interval
363
- records = [
364
- [{"0" => 1}],
365
- [{"1" => nil}],
366
- ]
367
- target = build(:month_interval, records)
368
- assert_equal(records, target.raw_records)
369
- end
370
-
371
- def test_day_time_interval
372
- records = [
373
- [{"0" => {day: 1, millisecond: 100}}],
374
- [{"1" => nil}],
375
- ]
376
- target = build(:day_time_interval, records)
377
- assert_equal(records, target.raw_records)
378
- end
379
-
380
- def test_month_day_nano_interval
381
- records = [
382
- [{"0" => {month: 1, day: 1, nanosecond: 100}}],
383
- [{"1" => nil}],
384
- ]
385
- target = build(:month_day_nano_interval, records)
386
- assert_equal(records, target.raw_records)
387
- end
388
-
389
- def test_list
390
- records = [
391
- [{"0" => [true, nil, false]}],
392
- [{"1" => nil}],
393
- ]
394
- target = build({
395
- type: :list,
396
- field: {
397
- name: :sub_element,
398
- type: :boolean,
399
- },
400
- },
401
- records)
402
- assert_equal(records, target.raw_records)
403
- end
404
-
405
- def test_struct
406
- records = [
407
- [{"0" => {"sub_field" => true}}],
408
- [{"1" => nil}],
409
- [{"0" => {"sub_field" => nil}}],
410
- ]
411
- target = build({
412
- type: :struct,
413
- fields: [
414
- {
415
- name: :sub_field,
416
- type: :boolean,
417
- },
418
- ],
419
- },
420
- records)
421
- assert_equal(records, target.raw_records)
422
- end
423
-
424
- def test_map
425
- records = [
426
- [{"0" => {"key1" => true, "key2" => nil}}],
427
- [{"1" => nil}],
428
- ]
429
- target = build({
430
- type: :map,
431
- key: :string,
432
- item: :boolean,
433
- },
434
- records)
435
- assert_equal(records, target.raw_records)
436
- end
437
-
438
- def test_sparse_union
439
- omit("Need to add support for SparseUnionArrayBuilder")
440
- records = [
441
- [{"0" => {"field1" => true}}],
442
- [{"1" => nil}],
443
- [{"0" => {"field2" => nil}}],
444
- ]
445
- target = build({
446
- type: :sparse_union,
447
- fields: [
448
- {
449
- name: :field1,
450
- type: :boolean,
451
- },
452
- {
453
- name: :field2,
454
- type: :uint8,
455
- },
456
- ],
457
- type_codes: [0, 1],
458
- },
459
- records)
460
- assert_equal(records, target.raw_records)
461
- end
462
-
463
- def test_dense_union
464
- omit("Need to add support for DenseUnionArrayBuilder")
465
- records = [
466
- [{"0" => {"field1" => true}}],
467
- [{"1" => nil}],
468
- [{"0" => {"field2" => nil}}],
469
- ]
470
- target = build({
471
- type: :dense_union,
472
- fields: [
473
- {
474
- name: :field1,
475
- type: :boolean,
476
- },
477
- {
478
- name: :field2,
479
- type: :uint8,
480
- },
481
- ],
482
- type_codes: [0, 1],
483
- },
484
- records)
485
- assert_equal(records, target.raw_records)
486
- end
487
-
488
- def test_dictionary
489
- omit("Need to add support for DictionaryArrayBuilder")
490
- records = [
491
- [{"0" => "Ruby"}],
492
- [{"1" => nil}],
493
- [{"0" => "GLib"}],
494
- ]
495
- dictionary = Arrow::StringArray.new(["GLib", "Ruby"])
496
- target = build({
497
- type: :dictionary,
498
- index_data_type: :int8,
499
- dictionary: dictionary,
500
- ordered: true,
501
- },
502
- records)
503
- assert_equal(records, target.raw_records)
504
- end
505
- end
506
-
507
- class RawRecordsRecordBatchDenseUnionArrayTest < Test::Unit::TestCase
508
- include RawRecordsDenseUnionArrayTests
509
-
510
- def build(type, records)
511
- build_record_batch(type, records)
512
- end
513
- end
514
-
515
- class RawRecordsTableDenseUnionArrayTest < Test::Unit::TestCase
516
- include RawRecordsDenseUnionArrayTests
517
-
518
- def build(type, records)
519
- build_record_batch(type, records).to_table
520
- end
521
- end