-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
### Rationale for this change `arrow::Decimal32Type` data type has been introduced. It is also necessary to support the same data type in GLib. ### What changes are included in this PR? This PR implements `GArrowDecimal32DataType`. ### Are these changes tested? YES ### Are there any user-facing changes? Before this change `garrow_decimal_data_type_new()` returns `GArrowDecimal64DataType` if the precision is less than `garrow_decimal64_data_type_max_precision()`. After this change, it returns `GArrowDecimal32DataType` if the precision is less than garrow_decimal32_data_type_max_precision(). * GitHub Issue: #44392 Authored-by: Hiroyuki Sato <[email protected]> Signed-off-by: Sutou Kouhei <[email protected]>
- Loading branch information
1 parent
feafddd
commit 5b68eca
Showing
5 changed files
with
144 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
class TestDecimal32DataType < Test::Unit::TestCase | ||
def test_type | ||
data_type = Arrow::Decimal32DataType.new(2, 0) | ||
assert_equal(Arrow::Type::DECIMAL32, data_type.id) | ||
end | ||
|
||
def test_name | ||
data_type = Arrow::Decimal32DataType.new(2, 0) | ||
assert_equal("decimal32", data_type.name) | ||
end | ||
|
||
def test_to_s | ||
data_type = Arrow::Decimal32DataType.new(2, 0) | ||
assert_equal("decimal32(2, 0)", data_type.to_s) | ||
end | ||
|
||
def test_precision | ||
data_type = Arrow::Decimal32DataType.new(8, 2) | ||
assert_equal(8, data_type.precision) | ||
end | ||
|
||
def test_scale | ||
data_type = Arrow::Decimal32DataType.new(8, 2) | ||
assert_equal(2, data_type.scale) | ||
end | ||
|
||
def test_decimal_data_type_new | ||
assert_equal(Arrow::Decimal32DataType.new(3, 2), | ||
Arrow::DecimalDataType.new(3, 2)) | ||
end | ||
|
||
def test_invalid_precision | ||
assert_raise(Arrow::Error::Invalid) do | ||
Arrow::Decimal32DataType.new(10, 1) | ||
end | ||
end | ||
end |