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,511 +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 RawRecordsSparseUnionArrayTests
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: :sparse_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
- arrays = schema.fields[0].data_type.fields.collect do |field|
44
- sub_schema = Arrow::Schema.new([field])
45
- sub_records = records.collect do |record|
46
- [record[0].nil? ? nil : record[0][field.name]]
47
- end
48
- sub_record_batch = Arrow::RecordBatch.new(sub_schema,
49
- sub_records)
50
- sub_record_batch.columns[0].data
51
- end
52
- records.each do |record|
53
- column = record[0]
54
- if column.key?("0")
55
- type_ids << type_codes[0]
56
- elsif column.key?("1")
57
- type_ids << type_codes[1]
58
- end
59
- end
60
- union_array = Arrow::SparseUnionArray.new(schema.fields[0].data_type,
61
- Arrow::Int8Array.new(type_ids),
62
- arrays)
63
- schema = Arrow::Schema.new(column: union_array.value_data_type)
64
- Arrow::RecordBatch.new(schema,
65
- records.size,
66
- [union_array])
67
- end
68
-
69
- def test_null
70
- records = [
71
- [{"0" => nil}],
72
- ]
73
- target = build(:null, records)
74
- assert_equal(records, target.raw_records)
75
- end
76
-
77
- def test_boolean
78
- records = [
79
- [{"0" => true}],
80
- [{"1" => nil}],
81
- ]
82
- target = build(:boolean, records)
83
- assert_equal(records, target.raw_records)
84
- end
85
-
86
- def test_int8
87
- records = [
88
- [{"0" => -(2 ** 7)}],
89
- [{"1" => nil}],
90
- ]
91
- target = build(:int8, records)
92
- assert_equal(records, target.raw_records)
93
- end
94
-
95
- def test_uint8
96
- records = [
97
- [{"0" => (2 ** 8) - 1}],
98
- [{"1" => nil}],
99
- ]
100
- target = build(:uint8, records)
101
- assert_equal(records, target.raw_records)
102
- end
103
-
104
- def test_int16
105
- records = [
106
- [{"0" => -(2 ** 15)}],
107
- [{"1" => nil}],
108
- ]
109
- target = build(:int16, records)
110
- assert_equal(records, target.raw_records)
111
- end
112
-
113
- def test_uint16
114
- records = [
115
- [{"0" => (2 ** 16) - 1}],
116
- [{"1" => nil}],
117
- ]
118
- target = build(:uint16, records)
119
- assert_equal(records, target.raw_records)
120
- end
121
-
122
- def test_int32
123
- records = [
124
- [{"0" => -(2 ** 31)}],
125
- [{"1" => nil}],
126
- ]
127
- target = build(:int32, records)
128
- assert_equal(records, target.raw_records)
129
- end
130
-
131
- def test_uint32
132
- records = [
133
- [{"0" => (2 ** 32) - 1}],
134
- [{"1" => nil}],
135
- ]
136
- target = build(:uint32, records)
137
- assert_equal(records, target.raw_records)
138
- end
139
-
140
- def test_int64
141
- records = [
142
- [{"0" => -(2 ** 63)}],
143
- [{"1" => nil}],
144
- ]
145
- target = build(:int64, records)
146
- assert_equal(records, target.raw_records)
147
- end
148
-
149
- def test_uint64
150
- records = [
151
- [{"0" => (2 ** 64) - 1}],
152
- [{"1" => nil}],
153
- ]
154
- target = build(:uint64, records)
155
- assert_equal(records, target.raw_records)
156
- end
157
-
158
- def test_float
159
- records = [
160
- [{"0" => -1.0}],
161
- [{"1" => nil}],
162
- ]
163
- target = build(:float, records)
164
- assert_equal(records, target.raw_records)
165
- end
166
-
167
- def test_double
168
- records = [
169
- [{"0" => -1.0}],
170
- [{"1" => nil}],
171
- ]
172
- target = build(:double, records)
173
- assert_equal(records, target.raw_records)
174
- end
175
-
176
- def test_binary
177
- records = [
178
- [{"0" => "\xff".b}],
179
- [{"1" => nil}],
180
- ]
181
- target = build(:binary, records)
182
- assert_equal(records, target.raw_records)
183
- end
184
-
185
- def test_string
186
- records = [
187
- [{"0" => "Ruby"}],
188
- [{"1" => nil}],
189
- ]
190
- target = build(:string, records)
191
- assert_equal(records, target.raw_records)
192
- end
193
-
194
- def test_date32
195
- records = [
196
- [{"0" => Date.new(1960, 1, 1)}],
197
- [{"1" => nil}],
198
- ]
199
- target = build(:date32, records)
200
- assert_equal(records, target.raw_records)
201
- end
202
-
203
- def test_date64
204
- records = [
205
- [{"0" => DateTime.new(1960, 1, 1, 2, 9, 30)}],
206
- [{"1" => nil}],
207
- ]
208
- target = build(:date64, records)
209
- assert_equal(records, target.raw_records)
210
- end
211
-
212
- def test_timestamp_second
213
- records = [
214
- [{"0" => Time.parse("1960-01-01T02:09:30Z")}],
215
- [{"1" => nil}],
216
- ]
217
- target = build({
218
- type: :timestamp,
219
- unit: :second,
220
- },
221
- records)
222
- assert_equal(records, target.raw_records)
223
- end
224
-
225
- def test_timestamp_milli
226
- records = [
227
- [{"0" => Time.parse("1960-01-01T02:09:30.123Z")}],
228
- [{"1" => nil}],
229
- ]
230
- target = build({
231
- type: :timestamp,
232
- unit: :milli,
233
- },
234
- records)
235
- assert_equal(records, target.raw_records)
236
- end
237
-
238
- def test_timestamp_micro
239
- records = [
240
- [{"0" => Time.parse("1960-01-01T02:09:30.123456Z")}],
241
- [{"1" => nil}],
242
- ]
243
- target = build({
244
- type: :timestamp,
245
- unit: :micro,
246
- },
247
- records)
248
- assert_equal(records, target.raw_records)
249
- end
250
-
251
- def test_timestamp_nano
252
- records = [
253
- [{"0" => Time.parse("1960-01-01T02:09:30.123456789Z")}],
254
- [{"1" => nil}],
255
- ]
256
- target = build({
257
- type: :timestamp,
258
- unit: :nano,
259
- },
260
- records)
261
- assert_equal(records, target.raw_records)
262
- end
263
-
264
- def test_time32_second
265
- unit = Arrow::TimeUnit::SECOND
266
- records = [
267
- # 00:10:00
268
- [{"0" => Arrow::Time.new(unit, 60 * 10)}],
269
- [{"1" => nil}],
270
- ]
271
- target = build({
272
- type: :time32,
273
- unit: :second,
274
- },
275
- records)
276
- assert_equal(records, target.raw_records)
277
- end
278
-
279
- def test_time32_milli
280
- unit = Arrow::TimeUnit::MILLI
281
- records = [
282
- # 00:10:00.123
283
- [{"0" => Arrow::Time.new(unit, (60 * 10) * 1000 + 123)}],
284
- [{"1" => nil}],
285
- ]
286
- target = build({
287
- type: :time32,
288
- unit: :milli,
289
- },
290
- records)
291
- assert_equal(records, target.raw_records)
292
- end
293
-
294
- def test_time64_micro
295
- unit = Arrow::TimeUnit::MICRO
296
- records = [
297
- # 00:10:00.123456
298
- [{"0" => Arrow::Time.new(unit, (60 * 10) * 1_000_000 + 123_456)}],
299
- [{"1" => nil}],
300
- ]
301
- target = build({
302
- type: :time64,
303
- unit: :micro,
304
- },
305
- records)
306
- assert_equal(records, target.raw_records)
307
- end
308
-
309
- def test_time64_nano
310
- unit = Arrow::TimeUnit::NANO
311
- records = [
312
- # 00:10:00.123456789
313
- [{"0" => Arrow::Time.new(unit, (60 * 10) * 1_000_000_000 + 123_456_789)}],
314
- [{"1" => nil}],
315
- ]
316
- target = build({
317
- type: :time64,
318
- unit: :nano,
319
- },
320
- records)
321
- assert_equal(records, target.raw_records)
322
- end
323
-
324
- def test_decimal128
325
- records = [
326
- [{"0" => BigDecimal("92.92")}],
327
- [{"1" => nil}],
328
- ]
329
- target = build({
330
- type: :decimal128,
331
- precision: 8,
332
- scale: 2,
333
- },
334
- records)
335
- assert_equal(records, target.raw_records)
336
- end
337
-
338
- def test_decimal256
339
- records = [
340
- [{"0" => BigDecimal("92.92")}],
341
- [{"1" => nil}],
342
- ]
343
- target = build({
344
- type: :decimal256,
345
- precision: 38,
346
- scale: 2,
347
- },
348
- records)
349
- assert_equal(records, target.raw_records)
350
- end
351
-
352
- def test_month_interval
353
- records = [
354
- [{"0" => 1}],
355
- [{"1" => nil}],
356
- ]
357
- target = build(:month_interval, records)
358
- assert_equal(records, target.raw_records)
359
- end
360
-
361
- def test_day_time_interval
362
- records = [
363
- [{"0" => {day: 1, millisecond: 100}}],
364
- [{"1" => nil}],
365
- ]
366
- target = build(:day_time_interval, records)
367
- assert_equal(records, target.raw_records)
368
- end
369
-
370
- def test_month_day_nano_interval
371
- records = [
372
- [{"0" => {month: 1, day: 1, nanosecond: 100}}],
373
- [{"1" => nil}],
374
- ]
375
- target = build(:month_day_nano_interval, records)
376
- assert_equal(records, target.raw_records)
377
- end
378
-
379
- def test_list
380
- records = [
381
- [{"0" => [true, nil, false]}],
382
- [{"1" => nil}],
383
- ]
384
- target = build({
385
- type: :list,
386
- field: {
387
- name: :sub_element,
388
- type: :boolean,
389
- },
390
- },
391
- records)
392
- assert_equal(records, target.raw_records)
393
- end
394
-
395
- def test_struct
396
- records = [
397
- [{"0" => {"sub_field" => true}}],
398
- [{"1" => nil}],
399
- [{"0" => {"sub_field" => nil}}],
400
- ]
401
- target = build({
402
- type: :struct,
403
- fields: [
404
- {
405
- name: :sub_field,
406
- type: :boolean,
407
- },
408
- ],
409
- },
410
- records)
411
- assert_equal(records, target.raw_records)
412
- end
413
-
414
- def test_map
415
- records = [
416
- [{"0" => {"key1" => true, "key2" => nil}}],
417
- [{"1" => nil}],
418
- ]
419
- target = build({
420
- type: :map,
421
- key: :string,
422
- item: :boolean,
423
- },
424
- records)
425
- assert_equal(records, target.raw_records)
426
- end
427
-
428
- def test_sparse_union
429
- omit("Need to add support for SparseUnionArrayBuilder")
430
- records = [
431
- [{"0" => {"field1" => true}}],
432
- [{"1" => nil}],
433
- [{"0" => {"field2" => nil}}],
434
- ]
435
- target = build({
436
- type: :sparse_union,
437
- fields: [
438
- {
439
- name: :field1,
440
- type: :boolean,
441
- },
442
- {
443
- name: :field2,
444
- type: :uint8,
445
- },
446
- ],
447
- type_codes: [0, 1],
448
- },
449
- records)
450
- assert_equal(records, target.raw_records)
451
- end
452
-
453
- def test_dense_union
454
- omit("Need to add support for DenseUnionArrayBuilder")
455
- records = [
456
- [{"0" => {"field1" => true}}],
457
- [{"1" => nil}],
458
- [{"0" => {"field2" => nil}}],
459
- ]
460
- target = build({
461
- type: :dense_union,
462
- fields: [
463
- {
464
- name: :field1,
465
- type: :boolean,
466
- },
467
- {
468
- name: :field2,
469
- type: :uint8,
470
- },
471
- ],
472
- type_codes: [0, 1],
473
- },
474
- records)
475
- assert_equal(records, target.raw_records)
476
- end
477
-
478
- def test_dictionary
479
- omit("Need to add support for DictionaryArrayBuilder")
480
- records = [
481
- [{"0" => "Ruby"}],
482
- [{"1" => nil}],
483
- [{"0" => "GLib"}],
484
- ]
485
- dictionary = Arrow::StringArray.new(["GLib", "Ruby"])
486
- target = build({
487
- type: :dictionary,
488
- index_data_type: :int8,
489
- dictionary: dictionary,
490
- ordered: true,
491
- },
492
- records)
493
- assert_equal(records, target.raw_records)
494
- end
495
- end
496
-
497
- class RawRecordsRecordBatchSparseUnionArrayTest < Test::Unit::TestCase
498
- include RawRecordsSparseUnionArrayTests
499
-
500
- def build(type, records)
501
- build_record_batch(type, records)
502
- end
503
- end
504
-
505
- class RawRecordsTableSparseUnionArrayTest < Test::Unit::TestCase
506
- include RawRecordsSparseUnionArrayTests
507
-
508
- def build(type, records)
509
- build_record_batch(type, records).to_table
510
- end
511
- end