jonkeane commented on a change in pull request #11898:
URL: https://github.com/apache/arrow/pull/11898#discussion_r772424604
##########
File path: r/tests/testthat/test-data-type.R
##########
@@ -386,20 +386,34 @@ test_that("DictionaryType validation", {
test_that("decimal type and validation", {
expect_r6_class(decimal(4, 2), "Decimal128Type")
+ expect_r6_class(decimal(39, 2), "Decimal256Type")
- expect_error(decimal("four"), '"precision" must be an integer')
- expect_error(decimal(4, "two"), '"scale" must be an integer')
- expect_error(decimal(NA, 2), '"precision" must be an integer')
- expect_error(decimal(4, NA), '"scale" must be an integer')
+ expect_error(decimal("four"), "`precision` must be an integer")
+ expect_error(decimal(4, "two"), "`scale` must be an integer")
+ expect_error(decimal(NA, 2), "`precision` must be an integer")
+ expect_error(decimal(4, NA), "`scale` must be an integer")
+
+ # decimal() creates either decimal128 or decimal256 based on precision
+ expect_identical(class(decimal(38, 2)), class(decimal128(38, 2)))
+ expect_identical(class(decimal(39, 2)), class(decimal256(38, 2)))
- # decimal() is just an alias for decimal128() for backwards compatibility
expect_r6_class(decimal128(4, 2), "Decimal128Type")
- expect_identical(class(decimal(2, 4)), class(decimal128(2, 4)))
- expect_error(decimal128("four"), '"precision" must be an integer')
- expect_error(decimal128(4, "two"), '"scale" must be an integer')
- expect_error(decimal128(NA, 2), '"precision" must be an integer')
- expect_error(decimal128(4, NA), '"scale" must be an integer')
+ expect_error(decimal128("four"), "`precision` must be an integer")
+ expect_error(decimal128(4, "two"), "`scale` must be an integer")
+ expect_error(decimal128(NA, 2), "`precision` must be an integer")
+ expect_error(decimal128(4, NA), "`scale` must be an integer")
+ expect_error(decimal128(3:4, NA), "`precision` must have size 1. not size 2")
+ expect_error(decimal128(4, 2:3), "`scale` must have size 1. not size 2")
+
+ expect_r6_class(decimal256(4, 2), "Decimal256Type")
+
+ expect_error(decimal256("four"), "`precision` must be an integer")
+ expect_error(decimal256(4, "two"), "`scale` must be an integer")
+ expect_error(decimal256(NA, 2), "`precision` must be an integer")
+ expect_error(decimal256(4, NA), "`scale` must be an integer")
+ expect_error(decimal256(3:4, NA), "`precision` must have size 1. not size 2")
+ expect_error(decimal256(4, 2:3), "`scale` must have size 1. not size 2")
Review comment:
Let's do (1), and then add a TODO note to the tests here that reference
that ticket
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]