red-arrow 18.1.0 → 19.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. checksums.yaml +4 -4
  2. data/lib/arrow/array.rb +7 -4
  3. data/lib/arrow/column.rb +4 -4
  4. data/lib/arrow/jruby/array-builder.rb +114 -0
  5. data/lib/arrow/jruby/array.rb +109 -0
  6. data/{test/helper/fixture.rb → lib/arrow/jruby/chunked-array.rb} +14 -6
  7. data/lib/arrow/jruby/compression-type.rb +26 -0
  8. data/{test/test-boolean-scalar.rb → lib/arrow/jruby/csv-read-options.rb} +12 -6
  9. data/{test/test-map-data-type.rb → lib/arrow/jruby/data-type.rb} +24 -12
  10. data/lib/arrow/jruby/decimal128.rb +28 -0
  11. data/lib/arrow/jruby/decimal256.rb +28 -0
  12. data/{test/fixture/null-with-double-quote.csv → lib/arrow/jruby/error.rb} +7 -4
  13. data/lib/arrow/jruby/file-system.rb +24 -0
  14. data/{test/test-null-array.rb → lib/arrow/jruby/function.rb} +5 -4
  15. data/lib/arrow/jruby/record-batch-iterator.rb +24 -0
  16. data/{test/fixture/integer-float.csv → lib/arrow/jruby/record-batch.rb} +8 -4
  17. data/{test/fixture/float-integer.csv → lib/arrow/jruby/sort-key.rb} +8 -4
  18. data/lib/arrow/jruby/sort-options.rb +24 -0
  19. data/lib/arrow/jruby/stream-listener-raw.rb +25 -0
  20. data/{test/test-rolling-window.rb → lib/arrow/jruby/table.rb} +19 -19
  21. data/lib/arrow/jruby/writable.rb +24 -0
  22. data/lib/arrow/jruby.rb +52 -0
  23. data/lib/arrow/libraries.rb +126 -0
  24. data/lib/arrow/list-array-builder.rb +1 -0
  25. data/lib/arrow/loader.rb +3 -111
  26. data/{test/fixture/null-without-double-quote.csv → lib/arrow/ruby.rb} +6 -4
  27. data/lib/arrow/version.rb +1 -1
  28. data/lib/arrow.rb +2 -7
  29. data/red-arrow.gemspec +15 -6
  30. metadata +26 -229
  31. data/test/each-raw-record/test-basic-arrays.rb +0 -411
  32. data/test/each-raw-record/test-dense-union-array.rb +0 -566
  33. data/test/each-raw-record/test-dictionary-array.rb +0 -341
  34. data/test/each-raw-record/test-list-array.rb +0 -628
  35. data/test/each-raw-record/test-map-array.rb +0 -507
  36. data/test/each-raw-record/test-multiple-columns.rb +0 -72
  37. data/test/each-raw-record/test-sparse-union-array.rb +0 -528
  38. data/test/each-raw-record/test-struct-array.rb +0 -529
  39. data/test/each-raw-record/test-table.rb +0 -47
  40. data/test/fixture/TestOrcFile.test1.orc +0 -0
  41. data/test/fixture/with-header-float.csv +0 -20
  42. data/test/fixture/with-header.csv +0 -20
  43. data/test/fixture/without-header-float.csv +0 -19
  44. data/test/fixture/without-header.csv +0 -19
  45. data/test/helper/omittable.rb +0 -49
  46. data/test/helper.rb +0 -31
  47. data/test/raw-records/test-basic-arrays.rb +0 -405
  48. data/test/raw-records/test-dense-union-array.rb +0 -566
  49. data/test/raw-records/test-dictionary-array.rb +0 -341
  50. data/test/raw-records/test-list-array.rb +0 -628
  51. data/test/raw-records/test-map-array.rb +0 -507
  52. data/test/raw-records/test-multiple-columns.rb +0 -65
  53. data/test/raw-records/test-sparse-union-array.rb +0 -556
  54. data/test/raw-records/test-struct-array.rb +0 -529
  55. data/test/raw-records/test-table.rb +0 -47
  56. data/test/run-test.rb +0 -71
  57. data/test/test-array-builder.rb +0 -198
  58. data/test/test-array.rb +0 -332
  59. data/test/test-bigdecimal.rb +0 -40
  60. data/test/test-binary-dictionary-array-builder.rb +0 -103
  61. data/test/test-buffer.rb +0 -49
  62. data/test/test-chunked-array.rb +0 -198
  63. data/test/test-column.rb +0 -123
  64. data/test/test-csv-loader.rb +0 -297
  65. data/test/test-data-type.rb +0 -84
  66. data/test/test-date32-array.rb +0 -24
  67. data/test/test-date64-array.rb +0 -25
  68. data/test/test-decimal128-array-builder.rb +0 -126
  69. data/test/test-decimal128-array.rb +0 -47
  70. data/test/test-decimal128-data-type.rb +0 -31
  71. data/test/test-decimal128.rb +0 -126
  72. data/test/test-decimal256-array-builder.rb +0 -126
  73. data/test/test-decimal256-array.rb +0 -47
  74. data/test/test-decimal256-data-type.rb +0 -31
  75. data/test/test-decimal256.rb +0 -126
  76. data/test/test-dense-union-array.rb +0 -42
  77. data/test/test-dense-union-data-type.rb +0 -41
  78. data/test/test-dictionary-array.rb +0 -41
  79. data/test/test-dictionary-data-type.rb +0 -40
  80. data/test/test-expression.rb +0 -51
  81. data/test/test-feather.rb +0 -49
  82. data/test/test-field.rb +0 -117
  83. data/test/test-file-output-stream.rb +0 -54
  84. data/test/test-fixed-size-binary-array-builder.rb +0 -92
  85. data/test/test-fixed-size-binary-array.rb +0 -36
  86. data/test/test-float-scalar.rb +0 -46
  87. data/test/test-function.rb +0 -210
  88. data/test/test-group.rb +0 -193
  89. data/test/test-half-float-array.rb +0 -43
  90. data/test/test-half-float.rb +0 -130
  91. data/test/test-list-array-builder.rb +0 -79
  92. data/test/test-list-array.rb +0 -32
  93. data/test/test-list-data-type.rb +0 -69
  94. data/test/test-map-array-builder.rb +0 -110
  95. data/test/test-map-array.rb +0 -33
  96. data/test/test-memory-view.rb +0 -434
  97. data/test/test-orc.rb +0 -173
  98. data/test/test-ractor.rb +0 -34
  99. data/test/test-record-batch-builder.rb +0 -125
  100. data/test/test-record-batch-file-reader.rb +0 -136
  101. data/test/test-record-batch-iterator.rb +0 -37
  102. data/test/test-record-batch-reader.rb +0 -46
  103. data/test/test-record-batch-stream-reader.rb +0 -129
  104. data/test/test-record-batch.rb +0 -182
  105. data/test/test-scalar.rb +0 -65
  106. data/test/test-schema.rb +0 -134
  107. data/test/test-slicer.rb +0 -589
  108. data/test/test-sort-indices.rb +0 -40
  109. data/test/test-sort-key.rb +0 -81
  110. data/test/test-sort-options.rb +0 -58
  111. data/test/test-sparse-union-array.rb +0 -38
  112. data/test/test-sparse-union-data-type.rb +0 -41
  113. data/test/test-stream-listener.rb +0 -60
  114. data/test/test-string-dictionary-array-builder.rb +0 -103
  115. data/test/test-struct-array-builder.rb +0 -184
  116. data/test/test-struct-array.rb +0 -94
  117. data/test/test-struct-data-type.rb +0 -112
  118. data/test/test-table.rb +0 -1530
  119. data/test/test-tensor.rb +0 -297
  120. data/test/test-time.rb +0 -288
  121. data/test/test-time32-array.rb +0 -81
  122. data/test/test-time32-data-type.rb +0 -42
  123. data/test/test-time64-array.rb +0 -81
  124. data/test/test-time64-data-type.rb +0 -42
  125. data/test/test-timestamp-array.rb +0 -45
  126. data/test/test-timestamp-data-type.rb +0 -42
  127. data/test/values/test-basic-arrays.rb +0 -335
  128. data/test/values/test-dense-union-array.rb +0 -552
  129. data/test/values/test-dictionary-array.rb +0 -325
  130. data/test/values/test-list-array.rb +0 -587
  131. data/test/values/test-map-array.rb +0 -489
  132. data/test/values/test-sparse-union-array.rb +0 -543
  133. data/test/values/test-struct-array.rb +0 -524
@@ -1,84 +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
- class DataTypeTest < Test::Unit::TestCase
19
- sub_test_case(".resolve") do
20
- test("DataType") do
21
- assert_equal(Arrow::BooleanDataType.new,
22
- Arrow::DataType.resolve(Arrow::BooleanDataType.new))
23
- end
24
-
25
- test("String") do
26
- assert_equal(Arrow::BooleanDataType.new,
27
- Arrow::DataType.resolve("boolean"))
28
- end
29
-
30
- test("Symbol") do
31
- assert_equal(Arrow::BooleanDataType.new,
32
- Arrow::DataType.resolve(:boolean))
33
- end
34
-
35
- test("Array") do
36
- field = Arrow::Field.new(:visible, :boolean)
37
- assert_equal(Arrow::ListDataType.new(field),
38
- Arrow::DataType.resolve([:list, field]))
39
- end
40
-
41
- test("Hash") do
42
- field = Arrow::Field.new(:visible, :boolean)
43
- assert_equal(Arrow::ListDataType.new(field),
44
- Arrow::DataType.resolve(type: :list, field: field))
45
- end
46
-
47
- test("_") do
48
- assert_equal(Arrow::FixedSizeBinaryDataType.new(10),
49
- Arrow::DataType.resolve([:fixed_size_binary, 10]))
50
- end
51
-
52
- test("abstract") do
53
- message =
54
- "abstract type: <:floating_point>: " +
55
- "use one of not abstract type: [" +
56
- "Arrow::DoubleDataType, " +
57
- "Arrow::FloatDataType, " +
58
- "Arrow::HalfFloatDataType]"
59
- assert_raise(ArgumentError.new(message)) do
60
- Arrow::DataType.resolve(:floating_point)
61
- end
62
- end
63
- end
64
-
65
- sub_test_case("instance methods") do
66
- def setup
67
- @data_type = Arrow::StringDataType.new
68
- end
69
-
70
- sub_test_case("#==") do
71
- test("Arrow::DataType") do
72
- assert do
73
- @data_type == @data_type
74
- end
75
- end
76
-
77
- test("not Arrow::DataType") do
78
- assert do
79
- not (@data_type == 29)
80
- end
81
- end
82
- end
83
- end
84
- end
@@ -1,24 +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
- class Date32ArrayTest < Test::Unit::TestCase
19
- test("#[]") do
20
- n_days_since_epoch = 17406 # 2017-08-28
21
- array = Arrow::Date32Array.new([n_days_since_epoch])
22
- assert_equal(Date.new(2017, 8, 28), array[0])
23
- end
24
- end
@@ -1,25 +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
- class Date64ArrayTest < Test::Unit::TestCase
19
- test("#[]") do
20
- n_msecs_since_epoch = 1503878400000 # 2017-08-28T00:00:00Z
21
- array = Arrow::Date64Array.new([n_msecs_since_epoch])
22
- assert_equal(DateTime.new(2017, 8, 28, 0, 0, 0),
23
- array[0])
24
- end
25
- end
@@ -1,126 +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
- class Decimal128ArrayBuilderTest < Test::Unit::TestCase
19
- def setup
20
- @data_type = Arrow::Decimal128DataType.new(3, 1)
21
- @builder = Arrow::Decimal128ArrayBuilder.new(@data_type)
22
- end
23
-
24
- sub_test_case("#append_value") do
25
- test("nil") do
26
- @builder.append_value(nil)
27
- array = @builder.finish
28
- assert_equal(nil, array[0])
29
- end
30
-
31
- test("Arrow::Decimal128") do
32
- @builder.append_value(Arrow::Decimal128.new("10.1"))
33
- array = @builder.finish
34
- assert_equal(BigDecimal("10.1"),
35
- array[0])
36
- end
37
-
38
- test("String") do
39
- @builder.append_value("10.1")
40
- array = @builder.finish
41
- assert_equal(BigDecimal("10.1"),
42
- array[0])
43
- end
44
-
45
- test("Float") do
46
- @builder.append_value(10.1)
47
- array = @builder.finish
48
- assert_equal(BigDecimal("10.1"),
49
- array[0])
50
- end
51
-
52
- test("BigDecimal") do
53
- @builder.append_value(BigDecimal("10.1"))
54
- array = @builder.finish
55
- assert_equal(BigDecimal("10.1"),
56
- array[0])
57
- end
58
-
59
- test("BigDecimal::NAN") do
60
- message = "can't use NaN as an Arrow::Decimal128Array value"
61
- assert_raise(FloatDomainError.new(message)) do
62
- @builder.append_value(BigDecimal::NAN)
63
- end
64
- end
65
-
66
- test("BigDecimal::INFINITY") do
67
- message = "can't use Infinity as an Arrow::Decimal128Array value"
68
- assert_raise(FloatDomainError.new(message)) do
69
- @builder.append_value(BigDecimal::INFINITY)
70
- end
71
- end
72
- end
73
-
74
- sub_test_case("#append_values") do
75
- test("mixed") do
76
- @builder.append_values([
77
- Arrow::Decimal128.new("10.1"),
78
- nil,
79
- "10.1",
80
- 10.1,
81
- BigDecimal("10.1"),
82
- ])
83
- array = @builder.finish
84
- assert_equal([
85
- BigDecimal("10.1"),
86
- nil,
87
- BigDecimal("10.1"),
88
- BigDecimal("10.1"),
89
- BigDecimal("10.1"),
90
- ],
91
- array.to_a)
92
- end
93
-
94
- test("is_valids") do
95
- @builder.append_values([
96
- Arrow::Decimal128.new("10.1"),
97
- Arrow::Decimal128.new("10.1"),
98
- Arrow::Decimal128.new("10.1"),
99
- ],
100
- [
101
- true,
102
- false,
103
- true,
104
- ])
105
- array = @builder.finish
106
- assert_equal([
107
- BigDecimal("10.1"),
108
- nil,
109
- BigDecimal("10.1"),
110
- ],
111
- array.to_a)
112
- end
113
-
114
- test("packed") do
115
- @builder.append_values(Arrow::Decimal128.new("10.1").to_bytes.to_s * 3,
116
- [true, false, true])
117
- array = @builder.finish
118
- assert_equal([
119
- BigDecimal("10.1"),
120
- nil,
121
- BigDecimal("10.1"),
122
- ],
123
- array.to_a)
124
- end
125
- end
126
- end
@@ -1,47 +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
- class Decimal128ArrayTest < Test::Unit::TestCase
19
- sub_test_case(".new") do
20
- test("build") do
21
- values = [
22
- 10.1,
23
- nil,
24
- "10.1",
25
- BigDecimal("10.1"),
26
- BigDecimal("1.11"),
27
- BigDecimal("1"),
28
- ]
29
- array = Arrow::Decimal128Array.new({precision: 3, scale: 1}, values)
30
- assert_equal([
31
- BigDecimal("10.1"),
32
- nil,
33
- BigDecimal("10.1"),
34
- BigDecimal("10.1"),
35
- BigDecimal("1.1"),
36
- BigDecimal("1"),
37
- ],
38
- array.to_a)
39
- end
40
- end
41
-
42
- def test_zero
43
- array = Arrow::Decimal128Array.new({precision: 38, scale: 9},
44
- [BigDecimal("0")])
45
- assert_equal(BigDecimal("0"), array[0])
46
- end
47
- end
@@ -1,31 +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
- class Decimal128DataTypeTest < Test::Unit::TestCase
19
- sub_test_case(".new") do
20
- test("ordered arguments") do
21
- assert_equal("decimal128(8, 2)",
22
- Arrow::Decimal128DataType.new(8, 2).to_s)
23
- end
24
-
25
- test("description") do
26
- assert_equal("decimal128(8, 2)",
27
- Arrow::Decimal128DataType.new(precision: 8,
28
- scale: 2).to_s)
29
- end
30
- end
31
- end
@@ -1,126 +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
- class Decimal128Test < Test::Unit::TestCase
19
- sub_test_case("instance methods") do
20
- def setup
21
- @decimal128 = Arrow::Decimal128.new("10.1")
22
- end
23
-
24
- sub_test_case("#==") do
25
- test("Arrow::Decimal128") do
26
- assert do
27
- @decimal128 == @decimal128
28
- end
29
- end
30
-
31
- test("String") do
32
- assert do
33
- @decimal128 == "10.1"
34
- end
35
- end
36
-
37
- test("Float") do
38
- assert do
39
- @decimal128 == 10.1
40
- end
41
- end
42
-
43
- test("not Arrow::Decimal128") do
44
- assert do
45
- not (@decimal128 == :"10.1")
46
- end
47
- end
48
- end
49
-
50
- sub_test_case("#!=") do
51
- test("Arrow::Decimal128") do
52
- assert do
53
- not (@decimal128 != @decimal128)
54
- end
55
- end
56
-
57
- test("String") do
58
- assert do
59
- not (@decimal128 != "10.1")
60
- end
61
- end
62
-
63
- test("Float") do
64
- assert do
65
- not (@decimal128 != 10.1)
66
- end
67
- end
68
-
69
- test("not Arrow::Decimal128") do
70
- assert do
71
- @decimal128 != :"10.1"
72
- end
73
- end
74
- end
75
-
76
- sub_test_case("#to_s") do
77
- test("default") do
78
- assert_equal("101",
79
- @decimal128.to_s)
80
- end
81
-
82
- test("scale") do
83
- assert_equal("10.1",
84
- @decimal128.to_s(1))
85
- end
86
- end
87
-
88
- test("#abs") do
89
- decimal128 = Arrow::Decimal128.new("-10.1")
90
- assert_equal([
91
- Arrow::Decimal128.new("-10.1"),
92
- Arrow::Decimal128.new("10.1"),
93
- ],
94
- [
95
- decimal128,
96
- decimal128.abs,
97
- ])
98
- end
99
-
100
- test("#abs!") do
101
- decimal128 = Arrow::Decimal128.new("-10.1")
102
- decimal128.abs!
103
- assert_equal(Arrow::Decimal128.new("10.1"),
104
- decimal128)
105
- end
106
-
107
- test("#negate") do
108
- decimal128 = Arrow::Decimal128.new("-10.1")
109
- assert_equal([
110
- Arrow::Decimal128.new("-10.1"),
111
- Arrow::Decimal128.new("10.1"),
112
- ],
113
- [
114
- decimal128,
115
- decimal128.negate,
116
- ])
117
- end
118
-
119
- test("#negate!") do
120
- decimal128 = Arrow::Decimal128.new("-10.1")
121
- decimal128.negate!
122
- assert_equal(Arrow::Decimal128.new("10.1"),
123
- decimal128)
124
- end
125
- end
126
- end
@@ -1,126 +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
- class Decimal256ArrayBuilderTest < Test::Unit::TestCase
19
- def setup
20
- @data_type = Arrow::Decimal256DataType.new(3, 1)
21
- @builder = Arrow::Decimal256ArrayBuilder.new(@data_type)
22
- end
23
-
24
- sub_test_case("#append_value") do
25
- test("nil") do
26
- @builder.append_value(nil)
27
- array = @builder.finish
28
- assert_equal(nil, array[0])
29
- end
30
-
31
- test("Arrow::Decimal256") do
32
- @builder.append_value(Arrow::Decimal256.new("10.1"))
33
- array = @builder.finish
34
- assert_equal(BigDecimal("10.1"),
35
- array[0])
36
- end
37
-
38
- test("String") do
39
- @builder.append_value("10.1")
40
- array = @builder.finish
41
- assert_equal(BigDecimal("10.1"),
42
- array[0])
43
- end
44
-
45
- test("Float") do
46
- @builder.append_value(10.1)
47
- array = @builder.finish
48
- assert_equal(BigDecimal("10.1"),
49
- array[0])
50
- end
51
-
52
- test("BigDecimal") do
53
- @builder.append_value(BigDecimal("10.1"))
54
- array = @builder.finish
55
- assert_equal(BigDecimal("10.1"),
56
- array[0])
57
- end
58
-
59
- test("BigDecimal::NAN") do
60
- message = "can't use NaN as an Arrow::Decimal256Array value"
61
- assert_raise(FloatDomainError.new(message)) do
62
- @builder.append_value(BigDecimal::NAN)
63
- end
64
- end
65
-
66
- test("BigDecimal::INFINITY") do
67
- message = "can't use Infinity as an Arrow::Decimal256Array value"
68
- assert_raise(FloatDomainError.new(message)) do
69
- @builder.append_value(BigDecimal::INFINITY)
70
- end
71
- end
72
- end
73
-
74
- sub_test_case("#append_values") do
75
- test("mixed") do
76
- @builder.append_values([
77
- Arrow::Decimal256.new("10.1"),
78
- nil,
79
- "10.1",
80
- 10.1,
81
- BigDecimal("10.1"),
82
- ])
83
- array = @builder.finish
84
- assert_equal([
85
- BigDecimal("10.1"),
86
- nil,
87
- BigDecimal("10.1"),
88
- BigDecimal("10.1"),
89
- BigDecimal("10.1"),
90
- ],
91
- array.to_a)
92
- end
93
-
94
- test("is_valids") do
95
- @builder.append_values([
96
- Arrow::Decimal256.new("10.1"),
97
- Arrow::Decimal256.new("10.1"),
98
- Arrow::Decimal256.new("10.1"),
99
- ],
100
- [
101
- true,
102
- false,
103
- true,
104
- ])
105
- array = @builder.finish
106
- assert_equal([
107
- BigDecimal("10.1"),
108
- nil,
109
- BigDecimal("10.1"),
110
- ],
111
- array.to_a)
112
- end
113
-
114
- test("packed") do
115
- @builder.append_values(Arrow::Decimal256.new("10.1").to_bytes.to_s * 3,
116
- [true, false, true])
117
- array = @builder.finish
118
- assert_equal([
119
- BigDecimal("10.1"),
120
- nil,
121
- BigDecimal("10.1"),
122
- ],
123
- array.to_a)
124
- end
125
- end
126
- end
@@ -1,47 +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
- class Decimal256ArrayTest < Test::Unit::TestCase
19
- sub_test_case(".new") do
20
- test("build") do
21
- values = [
22
- 10.1,
23
- nil,
24
- "10.1",
25
- BigDecimal("10.1"),
26
- BigDecimal("1.11"),
27
- BigDecimal("1"),
28
- ]
29
- array = Arrow::Decimal256Array.new({precision: 3, scale: 1}, values)
30
- assert_equal([
31
- BigDecimal("10.1"),
32
- nil,
33
- BigDecimal("10.1"),
34
- BigDecimal("10.1"),
35
- BigDecimal("1.1"),
36
- BigDecimal("1"),
37
- ],
38
- array.to_a)
39
- end
40
- end
41
-
42
- def test_zero
43
- array = Arrow::Decimal256Array.new({precision: 38, scale: 9},
44
- [BigDecimal("0")])
45
- assert_equal(BigDecimal("0"), array[0])
46
- end
47
- end
@@ -1,31 +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
- class Decimal256DataTypeTest < Test::Unit::TestCase
19
- sub_test_case(".new") do
20
- test("ordered arguments") do
21
- assert_equal("decimal256(8, 2)",
22
- Arrow::Decimal256DataType.new(8, 2).to_s)
23
- end
24
-
25
- test("description") do
26
- assert_equal("decimal256(8, 2)",
27
- Arrow::Decimal256DataType.new(precision: 8,
28
- scale: 2).to_s)
29
- end
30
- end
31
- end