red-arrow 16.1.0 → 18.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/arrow/extconf.rb +8 -1
- data/lib/arrow/field-containable.rb +1 -1
- data/lib/arrow/loader.rb +12 -0
- data/lib/arrow/stream-decoder.rb +29 -0
- data/lib/arrow/stream-listener.rb +47 -0
- data/lib/arrow/table-formatter.rb +33 -7
- data/lib/arrow/table-list-formatter.rb +3 -3
- data/lib/arrow/table-table-formatter.rb +7 -0
- data/lib/arrow/version.rb +1 -1
- data/red-arrow.gemspec +1 -1
- data/test/test-csv-loader.rb +40 -32
- data/test/test-decimal128-array.rb +6 -0
- data/test/test-decimal256-array.rb +6 -0
- data/test/test-group.rb +13 -0
- data/test/test-schema.rb +1 -1
- data/test/test-slicer.rb +191 -154
- data/test/test-stream-listener.rb +60 -0
- data/test/test-struct-data-type.rb +1 -1
- data/test/test-table.rb +305 -230
- metadata +13 -9
data/test/test-table.rb
CHANGED
@@ -87,24 +87,26 @@ class TableTest < Test::Unit::TestCase
|
|
87
87
|
target_rows_raw = [nil, true, true, false, true, false, true, true]
|
88
88
|
target_rows = Arrow::BooleanArray.new(target_rows_raw)
|
89
89
|
assert_equal(<<-TABLE, @table.slice(target_rows).to_s)
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
90
|
+
count visible
|
91
|
+
(uint8) (bool)
|
92
|
+
0 2 false
|
93
|
+
1 4 (null)
|
94
|
+
2 16 true
|
95
|
+
3 64 (null)
|
96
|
+
4 128 (null)
|
96
97
|
TABLE
|
97
98
|
end
|
98
99
|
|
99
100
|
test("Array: boolean") do
|
100
101
|
target_rows_raw = [nil, true, true, false, true, false, true, true]
|
101
102
|
assert_equal(<<-TABLE, @table.slice(target_rows_raw).to_s)
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
103
|
+
count visible
|
104
|
+
(uint8) (bool)
|
105
|
+
0 2 false
|
106
|
+
1 4 (null)
|
107
|
+
2 16 true
|
108
|
+
3 64 (null)
|
109
|
+
4 128 (null)
|
108
110
|
TABLE
|
109
111
|
end
|
110
112
|
|
@@ -131,83 +133,93 @@ class TableTest < Test::Unit::TestCase
|
|
131
133
|
|
132
134
|
test("Range: positive: include end") do
|
133
135
|
assert_equal(<<-TABLE, @table.slice(2..4).to_s)
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
136
|
+
count visible
|
137
|
+
(uint8) (bool)
|
138
|
+
0 4 (null)
|
139
|
+
1 8 true
|
140
|
+
2 16 true
|
138
141
|
TABLE
|
139
142
|
end
|
140
143
|
|
141
144
|
test("Range: positive: exclude end") do
|
142
145
|
assert_equal(<<-TABLE, @table.slice(2...4).to_s)
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
+
count visible
|
147
|
+
(uint8) (bool)
|
148
|
+
0 4 (null)
|
149
|
+
1 8 true
|
146
150
|
TABLE
|
147
151
|
end
|
148
152
|
|
149
153
|
test("Range: negative: include end") do
|
150
154
|
assert_equal(<<-TABLE, @table.slice(-4..-2).to_s)
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
+
count visible
|
156
|
+
(uint8) (bool)
|
157
|
+
0 16 true
|
158
|
+
1 32 false
|
159
|
+
2 64 (null)
|
155
160
|
TABLE
|
156
161
|
end
|
157
162
|
|
158
163
|
test("Range: negative: exclude end") do
|
159
164
|
assert_equal(<<-TABLE, @table.slice(-4...-2).to_s)
|
160
|
-
|
161
|
-
|
162
|
-
|
165
|
+
count visible
|
166
|
+
(uint8) (bool)
|
167
|
+
0 16 true
|
168
|
+
1 32 false
|
163
169
|
TABLE
|
164
170
|
end
|
165
171
|
|
166
172
|
test("[from, to]: positive") do
|
167
173
|
assert_equal(<<-TABLE, @table.slice(0, 2).to_s)
|
168
|
-
|
169
|
-
|
170
|
-
1
|
174
|
+
count visible
|
175
|
+
(uint8) (bool)
|
176
|
+
0 1 true
|
177
|
+
1 2 false
|
171
178
|
TABLE
|
172
179
|
end
|
173
180
|
|
174
181
|
test("[from, to]: negative") do
|
175
182
|
assert_equal(<<-TABLE, @table.slice(-4, 2).to_s)
|
176
|
-
|
177
|
-
|
178
|
-
|
183
|
+
count visible
|
184
|
+
(uint8) (bool)
|
185
|
+
0 16 true
|
186
|
+
1 32 false
|
179
187
|
TABLE
|
180
188
|
end
|
181
189
|
|
182
190
|
test("{key: Number}") do
|
183
191
|
assert_equal(<<-TABLE, @table.slice(count: 16).to_s)
|
184
|
-
|
185
|
-
|
192
|
+
count visible
|
193
|
+
(uint8) (bool)
|
194
|
+
0 16 true
|
186
195
|
TABLE
|
187
196
|
end
|
188
197
|
|
189
198
|
test("{key: String}") do
|
190
199
|
table = Arrow::Table.new(name: Arrow::StringArray.new(["a", "b", "c"]))
|
191
200
|
assert_equal(<<-TABLE, table.slice(name: 'b').to_s)
|
192
|
-
|
193
|
-
|
201
|
+
name
|
202
|
+
(utf8)
|
203
|
+
0 b
|
194
204
|
TABLE
|
195
205
|
end
|
196
206
|
|
197
207
|
test("{key: true}") do
|
198
208
|
assert_equal(<<-TABLE, @table.slice(visible: true).to_s)
|
199
|
-
|
200
|
-
|
201
|
-
1
|
202
|
-
|
209
|
+
count visible
|
210
|
+
(uint8) (bool)
|
211
|
+
0 1 true
|
212
|
+
1 8 true
|
213
|
+
2 16 true
|
203
214
|
TABLE
|
204
215
|
end
|
205
216
|
|
206
217
|
test("{key: false}") do
|
207
218
|
assert_equal(<<-TABLE, @table.slice(visible: false).to_s)
|
208
|
-
|
209
|
-
|
210
|
-
|
219
|
+
count visible
|
220
|
+
(uint8) (bool)
|
221
|
+
0 2 false
|
222
|
+
1 32 false
|
211
223
|
TABLE
|
212
224
|
end
|
213
225
|
|
@@ -218,11 +230,12 @@ class TableTest < Test::Unit::TestCase
|
|
218
230
|
omit("beginless range isn't supported")
|
219
231
|
end
|
220
232
|
assert_equal(<<-TABLE, @table.slice(count: range).to_s)
|
221
|
-
|
222
|
-
|
223
|
-
1
|
224
|
-
2
|
225
|
-
|
233
|
+
count visible
|
234
|
+
(uint8) (bool)
|
235
|
+
0 1 true
|
236
|
+
1 2 false
|
237
|
+
2 4 (null)
|
238
|
+
3 8 true
|
226
239
|
TABLE
|
227
240
|
end
|
228
241
|
|
@@ -233,10 +246,11 @@ class TableTest < Test::Unit::TestCase
|
|
233
246
|
omit("beginless range isn't supported")
|
234
247
|
end
|
235
248
|
assert_equal(<<-TABLE, @table.slice(count: range).to_s)
|
236
|
-
|
237
|
-
|
238
|
-
1
|
239
|
-
2
|
249
|
+
count visible
|
250
|
+
(uint8) (bool)
|
251
|
+
0 1 true
|
252
|
+
1 2 false
|
253
|
+
2 4 (null)
|
240
254
|
TABLE
|
241
255
|
end
|
242
256
|
|
@@ -247,39 +261,43 @@ class TableTest < Test::Unit::TestCase
|
|
247
261
|
omit("endless range isn't supported")
|
248
262
|
end
|
249
263
|
assert_equal(<<-TABLE, @table.slice(count: range).to_s)
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
264
|
+
count visible
|
265
|
+
(uint8) (bool)
|
266
|
+
0 16 true
|
267
|
+
1 32 false
|
268
|
+
2 64 (null)
|
269
|
+
3 128 (null)
|
255
270
|
TABLE
|
256
271
|
end
|
257
272
|
|
258
273
|
test("{key: Range}: include end") do
|
259
274
|
assert_equal(<<-TABLE, @table.slice(count: 1..16).to_s)
|
260
|
-
|
261
|
-
|
262
|
-
1
|
263
|
-
2
|
264
|
-
|
265
|
-
|
275
|
+
count visible
|
276
|
+
(uint8) (bool)
|
277
|
+
0 1 true
|
278
|
+
1 2 false
|
279
|
+
2 4 (null)
|
280
|
+
3 8 true
|
281
|
+
4 16 true
|
266
282
|
TABLE
|
267
283
|
end
|
268
284
|
|
269
285
|
test("{key: Range}: exclude end") do
|
270
286
|
assert_equal(<<-TABLE, @table.slice(count: 1...16).to_s)
|
271
|
-
|
272
|
-
|
273
|
-
1
|
274
|
-
2
|
275
|
-
|
287
|
+
count visible
|
288
|
+
(uint8) (bool)
|
289
|
+
0 1 true
|
290
|
+
1 2 false
|
291
|
+
2 4 (null)
|
292
|
+
3 8 true
|
276
293
|
TABLE
|
277
294
|
end
|
278
295
|
|
279
296
|
test("{key1: Range, key2: true}") do
|
280
297
|
assert_equal(<<-TABLE, @table.slice(count: 0..8, visible: false).to_s)
|
281
|
-
|
282
|
-
|
298
|
+
count visible
|
299
|
+
(uint8) (bool)
|
300
|
+
0 2 false
|
283
301
|
TABLE
|
284
302
|
end
|
285
303
|
|
@@ -372,44 +390,47 @@ class TableTest < Test::Unit::TestCase
|
|
372
390
|
test("add") do
|
373
391
|
name_array = Arrow::StringArray.new(["a", "b", "c", "d", "e", "f", "g", "h"])
|
374
392
|
assert_equal(<<-TABLE, @table.merge(:name => name_array).to_s)
|
375
|
-
|
376
|
-
|
377
|
-
1
|
378
|
-
2
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
393
|
+
count visible name
|
394
|
+
(uint8) (bool) (utf8)
|
395
|
+
0 1 true a
|
396
|
+
1 2 false b
|
397
|
+
2 4 (null) c
|
398
|
+
3 8 true d
|
399
|
+
4 16 true e
|
400
|
+
5 32 false f
|
401
|
+
6 64 (null) g
|
402
|
+
7 128 (null) h
|
384
403
|
TABLE
|
385
404
|
end
|
386
405
|
|
387
406
|
test("remove") do
|
388
407
|
assert_equal(<<-TABLE, @table.merge(:visible => nil).to_s)
|
389
|
-
|
390
|
-
|
391
|
-
1
|
392
|
-
2
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
408
|
+
count
|
409
|
+
(uint8)
|
410
|
+
0 1
|
411
|
+
1 2
|
412
|
+
2 4
|
413
|
+
3 8
|
414
|
+
4 16
|
415
|
+
5 32
|
416
|
+
6 64
|
417
|
+
7 128
|
398
418
|
TABLE
|
399
419
|
end
|
400
420
|
|
401
421
|
test("replace") do
|
402
422
|
visible_array = Arrow::Int32Array.new([1] * @visible_array.length)
|
403
423
|
assert_equal(<<-TABLE, @table.merge(:visible => visible_array).to_s)
|
404
|
-
|
405
|
-
|
406
|
-
1
|
407
|
-
2
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
424
|
+
count visible
|
425
|
+
(uint8) (int32)
|
426
|
+
0 1 1
|
427
|
+
1 2 1
|
428
|
+
2 4 1
|
429
|
+
3 8 1
|
430
|
+
4 16 1
|
431
|
+
5 32 1
|
432
|
+
6 64 1
|
433
|
+
7 128 1
|
413
434
|
TABLE
|
414
435
|
end
|
415
436
|
end
|
@@ -419,15 +440,16 @@ class TableTest < Test::Unit::TestCase
|
|
419
440
|
name_array = Arrow::StringArray.new(["a", "b", "c", "d", "e", "f", "g", "h"])
|
420
441
|
table = Arrow::Table.new("name" => name_array)
|
421
442
|
assert_equal(<<-TABLE, @table.merge(table).to_s)
|
422
|
-
|
423
|
-
|
424
|
-
1
|
425
|
-
2
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
443
|
+
count visible name
|
444
|
+
(uint8) (bool) (utf8)
|
445
|
+
0 1 true a
|
446
|
+
1 2 false b
|
447
|
+
2 4 (null) c
|
448
|
+
3 8 true d
|
449
|
+
4 16 true e
|
450
|
+
5 32 false f
|
451
|
+
6 64 (null) g
|
452
|
+
7 128 (null) h
|
431
453
|
TABLE
|
432
454
|
end
|
433
455
|
|
@@ -435,15 +457,16 @@ class TableTest < Test::Unit::TestCase
|
|
435
457
|
visible_array = Arrow::Int32Array.new([1] * @visible_array.length)
|
436
458
|
table = Arrow::Table.new("visible" => visible_array)
|
437
459
|
assert_equal(<<-TABLE, @table.merge(table).to_s)
|
438
|
-
|
439
|
-
|
440
|
-
1
|
441
|
-
2
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
460
|
+
count visible
|
461
|
+
(uint8) (int32)
|
462
|
+
0 1 1
|
463
|
+
1 2 1
|
464
|
+
2 4 1
|
465
|
+
3 8 1
|
466
|
+
4 16 1
|
467
|
+
5 32 1
|
468
|
+
6 64 1
|
469
|
+
7 128 1
|
447
470
|
TABLE
|
448
471
|
end
|
449
472
|
end
|
@@ -457,29 +480,31 @@ class TableTest < Test::Unit::TestCase
|
|
457
480
|
sub_test_case("#remove_column") do
|
458
481
|
test("String") do
|
459
482
|
assert_equal(<<-TABLE, @table.remove_column("visible").to_s)
|
460
|
-
|
461
|
-
|
462
|
-
1
|
463
|
-
2
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
483
|
+
count
|
484
|
+
(uint8)
|
485
|
+
0 1
|
486
|
+
1 2
|
487
|
+
2 4
|
488
|
+
3 8
|
489
|
+
4 16
|
490
|
+
5 32
|
491
|
+
6 64
|
492
|
+
7 128
|
469
493
|
TABLE
|
470
494
|
end
|
471
495
|
|
472
496
|
test("Symbol") do
|
473
497
|
assert_equal(<<-TABLE, @table.remove_column(:visible).to_s)
|
474
|
-
|
475
|
-
|
476
|
-
1
|
477
|
-
2
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
498
|
+
count
|
499
|
+
(uint8)
|
500
|
+
0 1
|
501
|
+
1 2
|
502
|
+
2 4
|
503
|
+
3 8
|
504
|
+
4 16
|
505
|
+
5 32
|
506
|
+
6 64
|
507
|
+
7 128
|
483
508
|
TABLE
|
484
509
|
end
|
485
510
|
|
@@ -491,29 +516,31 @@ class TableTest < Test::Unit::TestCase
|
|
491
516
|
|
492
517
|
test("Integer") do
|
493
518
|
assert_equal(<<-TABLE, @table.remove_column(1).to_s)
|
494
|
-
|
495
|
-
|
496
|
-
1
|
497
|
-
2
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
519
|
+
count
|
520
|
+
(uint8)
|
521
|
+
0 1
|
522
|
+
1 2
|
523
|
+
2 4
|
524
|
+
3 8
|
525
|
+
4 16
|
526
|
+
5 32
|
527
|
+
6 64
|
528
|
+
7 128
|
503
529
|
TABLE
|
504
530
|
end
|
505
531
|
|
506
532
|
test("negative integer") do
|
507
533
|
assert_equal(<<-TABLE, @table.remove_column(-1).to_s)
|
508
|
-
|
509
|
-
|
510
|
-
1
|
511
|
-
2
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
534
|
+
count
|
535
|
+
(uint8)
|
536
|
+
0 1
|
537
|
+
1 2
|
538
|
+
2 4
|
539
|
+
3 8
|
540
|
+
4 16
|
541
|
+
5 32
|
542
|
+
6 64
|
543
|
+
7 128
|
517
544
|
TABLE
|
518
545
|
end
|
519
546
|
|
@@ -544,29 +571,33 @@ class TableTest < Test::Unit::TestCase
|
|
544
571
|
|
545
572
|
test("names") do
|
546
573
|
assert_equal(<<-TABLE, @table.select_columns(:c, :a).to_s)
|
547
|
-
|
548
|
-
|
574
|
+
c a
|
575
|
+
(uint8) (uint8)
|
576
|
+
0 1 1
|
549
577
|
TABLE
|
550
578
|
end
|
551
579
|
|
552
580
|
test("range") do
|
553
581
|
assert_equal(<<-TABLE, @table.select_columns(2...4).to_s)
|
554
|
-
|
555
|
-
|
582
|
+
c d
|
583
|
+
(uint8) (uint8)
|
584
|
+
0 1 1
|
556
585
|
TABLE
|
557
586
|
end
|
558
587
|
|
559
588
|
test("indexes") do
|
560
589
|
assert_equal(<<-TABLE, @table.select_columns(0, -1, 2).to_s)
|
561
|
-
|
562
|
-
|
590
|
+
a e c
|
591
|
+
(uint8) (uint8) (uint8)
|
592
|
+
0 1 1 1
|
563
593
|
TABLE
|
564
594
|
end
|
565
595
|
|
566
596
|
test("mixed") do
|
567
597
|
assert_equal(<<-TABLE, @table.select_columns(:a, -1, 2..3).to_s)
|
568
|
-
|
569
|
-
|
598
|
+
a e c d
|
599
|
+
(uint8) (uint8) (uint8) (uint8)
|
600
|
+
0 1 1 1 1
|
570
601
|
TABLE
|
571
602
|
end
|
572
603
|
|
@@ -575,8 +606,9 @@ class TableTest < Test::Unit::TestCase
|
|
575
606
|
column.name == "a" or i.odd?
|
576
607
|
end
|
577
608
|
assert_equal(<<-TABLE, selected_table.to_s)
|
578
|
-
|
579
|
-
|
609
|
+
a b d
|
610
|
+
(uint8) (uint8) (uint8)
|
611
|
+
0 1 1 1
|
580
612
|
TABLE
|
581
613
|
end
|
582
614
|
|
@@ -585,15 +617,17 @@ class TableTest < Test::Unit::TestCase
|
|
585
617
|
column.name == "a"
|
586
618
|
end
|
587
619
|
assert_equal(<<-TABLE, selected_table.to_s)
|
588
|
-
|
589
|
-
|
620
|
+
a
|
621
|
+
(uint8)
|
622
|
+
0 1
|
590
623
|
TABLE
|
591
624
|
end
|
592
625
|
|
593
626
|
test("empty result") do
|
594
627
|
selected_table = @table.filter([false] * @table.size).select_columns(:a)
|
595
628
|
assert_equal(<<-TABLE, selected_table.to_s)
|
596
|
-
|
629
|
+
a
|
630
|
+
(uint8)
|
597
631
|
TABLE
|
598
632
|
end
|
599
633
|
end
|
@@ -682,7 +716,7 @@ class TableTest < Test::Unit::TestCase
|
|
682
716
|
output = create_output(".json")
|
683
717
|
# TODO: Implement this.
|
684
718
|
# @table.save(output, format: :json)
|
685
|
-
columns = ""
|
719
|
+
columns = +""
|
686
720
|
@table.each_record.each do |record|
|
687
721
|
column = {
|
688
722
|
"count" => record.count,
|
@@ -789,10 +823,11 @@ class TableTest < Test::Unit::TestCase
|
|
789
823
|
path = fixture_path("with-header.csv")
|
790
824
|
table = Arrow::Table.load(path, skip_lines: /^\#/)
|
791
825
|
assert_equal(<<-TABLE, table.to_s)
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
826
|
+
name score
|
827
|
+
(utf8) (int8)
|
828
|
+
0 alice 10
|
829
|
+
1 bob 29
|
830
|
+
2 chris -1
|
796
831
|
TABLE
|
797
832
|
end
|
798
833
|
|
@@ -808,10 +843,11 @@ chris,-1
|
|
808
843
|
CSV
|
809
844
|
end
|
810
845
|
assert_equal(<<-TABLE, Arrow::Table.load(file.path).to_s)
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
846
|
+
name score
|
847
|
+
(utf8) (int64)
|
848
|
+
0 alice 10
|
849
|
+
1 bob 29
|
850
|
+
2 chris -1
|
815
851
|
TABLE
|
816
852
|
end
|
817
853
|
|
@@ -826,10 +862,11 @@ chris\t-1
|
|
826
862
|
file.close
|
827
863
|
table = Arrow::Table.load(file.path)
|
828
864
|
assert_equal(<<-TABLE, table.to_s)
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
865
|
+
name score
|
866
|
+
(utf8) (int64)
|
867
|
+
0 alice 10
|
868
|
+
1 bob 29
|
869
|
+
2 chris -1
|
833
870
|
TABLE
|
834
871
|
end
|
835
872
|
end
|
@@ -881,7 +918,7 @@ chris\t-1
|
|
881
918
|
output.data.to_s,
|
882
919
|
content_type) do |port|
|
883
920
|
input = URI("http://127.0.0.1:#{port}#{path}")
|
884
|
-
loaded_table = Arrow::Table.load(input)
|
921
|
+
loaded_table = Arrow::Table.load(input, schema: @table.schema)
|
885
922
|
assert_equal(@table.to_s, loaded_table.to_s)
|
886
923
|
end
|
887
924
|
end
|
@@ -962,15 +999,16 @@ chris\t-1
|
|
962
999
|
packed_table = @table.pack
|
963
1000
|
column_n_chunks = packed_table.columns.collect {|c| c.data.n_chunks}
|
964
1001
|
assert_equal([[1, 1], <<-TABLE], [column_n_chunks, packed_table.to_s])
|
965
|
-
|
966
|
-
|
967
|
-
1
|
968
|
-
2
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
1002
|
+
count visible
|
1003
|
+
(uint8) (bool)
|
1004
|
+
0 1 true
|
1005
|
+
1 2 false
|
1006
|
+
2 4 (null)
|
1007
|
+
3 8 true
|
1008
|
+
4 16 true
|
1009
|
+
5 32 false
|
1010
|
+
6 64 (null)
|
1011
|
+
7 128 (null)
|
974
1012
|
TABLE
|
975
1013
|
end
|
976
1014
|
|
@@ -1009,19 +1047,20 @@ visible:
|
|
1009
1047
|
test(":list") do
|
1010
1048
|
assert_equal(<<-TABLE, @table.to_s(format: :list))
|
1011
1049
|
==================== 0 ====================
|
1012
|
-
count: 1
|
1013
|
-
visible: true
|
1050
|
+
count(uint8): 1
|
1051
|
+
visible(bool): true
|
1014
1052
|
==================== 1 ====================
|
1015
|
-
count: 2
|
1016
|
-
visible: false
|
1053
|
+
count(uint8): 2
|
1054
|
+
visible(bool): false
|
1017
1055
|
TABLE
|
1018
1056
|
end
|
1019
1057
|
|
1020
1058
|
test(":table") do
|
1021
1059
|
assert_equal(<<-TABLE, @table.to_s(format: :table))
|
1022
|
-
|
1023
|
-
|
1024
|
-
1
|
1060
|
+
count visible
|
1061
|
+
(uint8) (bool)
|
1062
|
+
0 1 true
|
1063
|
+
1 2 false
|
1025
1064
|
TABLE
|
1026
1065
|
end
|
1027
1066
|
|
@@ -1033,6 +1072,35 @@ visible: false
|
|
1033
1072
|
end
|
1034
1073
|
end
|
1035
1074
|
|
1075
|
+
sub_test_case(":show_column_type") do
|
1076
|
+
def setup
|
1077
|
+
columns = {
|
1078
|
+
"count" => Arrow::UInt8Array.new([1, 2]),
|
1079
|
+
"visible" => Arrow::BooleanArray.new([true, false]),
|
1080
|
+
}
|
1081
|
+
@table = Arrow::Table.new(columns)
|
1082
|
+
end
|
1083
|
+
|
1084
|
+
test(":list") do
|
1085
|
+
assert_equal(<<-TABLE, @table.to_s(format: :list, show_column_type: false))
|
1086
|
+
==================== 0 ====================
|
1087
|
+
count: 1
|
1088
|
+
visible: true
|
1089
|
+
==================== 1 ====================
|
1090
|
+
count: 2
|
1091
|
+
visible: false
|
1092
|
+
TABLE
|
1093
|
+
end
|
1094
|
+
|
1095
|
+
test(":table") do
|
1096
|
+
assert_equal(<<-TABLE, @table.to_s(format: :table, show_column_type: false))
|
1097
|
+
count visible
|
1098
|
+
0 1 true
|
1099
|
+
1 2 false
|
1100
|
+
TABLE
|
1101
|
+
end
|
1102
|
+
end
|
1103
|
+
|
1036
1104
|
sub_test_case("#==") do
|
1037
1105
|
test("Arrow::Table") do
|
1038
1106
|
assert do
|
@@ -1058,13 +1126,14 @@ visible: false
|
|
1058
1126
|
test("Array: boolean") do
|
1059
1127
|
filter = [nil, true, true, false, true, false, true, true]
|
1060
1128
|
assert_equal(<<-TABLE, @table.filter(filter, @options).to_s)
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
2
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1129
|
+
count visible
|
1130
|
+
(uint8) (bool)
|
1131
|
+
0 (null) (null)
|
1132
|
+
1 2 false
|
1133
|
+
2 4 (null)
|
1134
|
+
3 16 true
|
1135
|
+
4 64 (null)
|
1136
|
+
5 128 (null)
|
1068
1137
|
TABLE
|
1069
1138
|
end
|
1070
1139
|
|
@@ -1072,13 +1141,14 @@ visible: false
|
|
1072
1141
|
array = [nil, true, true, false, true, false, true, true]
|
1073
1142
|
filter = Arrow::BooleanArray.new(array)
|
1074
1143
|
assert_equal(<<-TABLE, @table.filter(filter, @options).to_s)
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
2
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1144
|
+
count visible
|
1145
|
+
(uint8) (bool)
|
1146
|
+
0 (null) (null)
|
1147
|
+
1 2 false
|
1148
|
+
2 4 (null)
|
1149
|
+
3 16 true
|
1150
|
+
4 64 (null)
|
1151
|
+
5 128 (null)
|
1082
1152
|
TABLE
|
1083
1153
|
end
|
1084
1154
|
|
@@ -1090,13 +1160,14 @@ visible: false
|
|
1090
1160
|
]
|
1091
1161
|
filter = Arrow::ChunkedArray.new(filter_chunks)
|
1092
1162
|
assert_equal(<<-TABLE, @table.filter(filter, @options).to_s)
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
2
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1163
|
+
count visible
|
1164
|
+
(uint8) (bool)
|
1165
|
+
0 (null) (null)
|
1166
|
+
1 2 false
|
1167
|
+
2 4 (null)
|
1168
|
+
3 16 true
|
1169
|
+
4 64 (null)
|
1170
|
+
5 128 (null)
|
1100
1171
|
TABLE
|
1101
1172
|
end
|
1102
1173
|
end
|
@@ -1105,20 +1176,22 @@ visible: false
|
|
1105
1176
|
test("Arrow: boolean") do
|
1106
1177
|
indices = [1, 0, 2]
|
1107
1178
|
assert_equal(<<-TABLE, @table.take(indices).to_s)
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1179
|
+
count visible
|
1180
|
+
(uint8) (bool)
|
1181
|
+
0 2 false
|
1182
|
+
1 1 true
|
1183
|
+
2 4 (null)
|
1112
1184
|
TABLE
|
1113
1185
|
end
|
1114
1186
|
|
1115
1187
|
test("Arrow::Array") do
|
1116
1188
|
indices = Arrow::Int16Array.new([1, 0, 2])
|
1117
1189
|
assert_equal(<<-TABLE, @table.take(indices).to_s)
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1190
|
+
count visible
|
1191
|
+
(uint8) (bool)
|
1192
|
+
0 2 false
|
1193
|
+
1 1 true
|
1194
|
+
2 4 (null)
|
1122
1195
|
TABLE
|
1123
1196
|
end
|
1124
1197
|
|
@@ -1129,10 +1202,11 @@ visible: false
|
|
1129
1202
|
]
|
1130
1203
|
indices = Arrow::ChunkedArray.new(chunks)
|
1131
1204
|
assert_equal(<<-TABLE, @table.take(indices).to_s)
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1205
|
+
count visible
|
1206
|
+
(uint8) (bool)
|
1207
|
+
0 2 false
|
1208
|
+
1 1 true
|
1209
|
+
2 4 (null)
|
1136
1210
|
TABLE
|
1137
1211
|
end
|
1138
1212
|
end
|
@@ -1144,9 +1218,10 @@ visible: false
|
|
1144
1218
|
table2 = Arrow::Table.new(b: [false])
|
1145
1219
|
concatenated = table1.concatenate([table2], unify_schemas: true)
|
1146
1220
|
assert_equal(<<-TABLE, concatenated.to_s)
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1221
|
+
a b
|
1222
|
+
(bool) (bool)
|
1223
|
+
0 true false
|
1224
|
+
1 (null) false
|
1150
1225
|
TABLE
|
1151
1226
|
end
|
1152
1227
|
end
|