dragosmg commented on a change in pull request #11898:
URL: https://github.com/apache/arrow/pull/11898#discussion_r772431694



##########
File path: r/tests/testthat/test-Array.R
##########
@@ -795,6 +795,26 @@ test_that("Array$create() should have helpful error", {
   expect_error(Array$create(list()), "Requires at least one element to infer")
   expect_error(Array$create(list(lgl, lgl, int)), "Expecting a logical vector")
   expect_error(Array$create(list(char, num, char)), "Expecting a character 
vector")
+
+  # hint at casting if direct fails and casting looks like it might work
+  expect_error(
+    Array$create(as.double(1:10), type = decimal(4, 2)),
+    "You might want to try casting manually"
+  )
+  # until ARROW-15159 is solved casting from integer to decimal requires a
+  # precision of at least 12
+  # precision < 12 => the attempt to cast errors and the original error message
+  # is shown
+  expect_error(
+    Array$create(1:10, type = decimal(11, 2)),
+    "NotImplemented: Extend"
+  )

Review comment:
       This was sort of hitting 2 birds with 1 stone. This is actually testing 
the `try()` attempt (more specifically its failure and fallback to the first 
error message). I agree this is dangerous as the error message will no longer 
appear once (once 
[ARROW-15159](https://issues.apache.org/jira/browse/ARROW-15159) is addressed. 




-- 
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]


Reply via email to