westonpace commented on code in PR #14232:
URL: https://github.com/apache/arrow/pull/14232#discussion_r1005993833
##########
cpp/src/arrow/compute/kernels/scalar_cast_test.cc:
##########
@@ -1910,6 +1919,30 @@ TEST(Cast, StringToFloating) {
}
}
+TEST(Cast, StringToDecimal) {
+ for (auto string_type : {utf8(), large_utf8()}) {
+ for (auto decimal_type : {decimal128(5, 2), decimal256(5, 2)}) {
+ auto strings =
+ ArrayFromJSON(string_type, R"(["0.01", null, "127.32", "200.43",
"0.54"])");
+ auto decimals =
+ ArrayFromJSON(decimal_type, R"(["0.01", null, "127.32", "200.43",
"0.54"])");
+ CheckCast(strings, decimals);
+
+ for (const auto& not_decimal : std::vector<std::string>{"z"}) {
+ auto options = CastOptions::Safe(decimal128(5, 2));
+ CheckCastFails(ArrayFromJSON(string_type, "[\"" + not_decimal +
"\"]"), options);
+ }
+
+#if !defined(_WIN32) || defined(NDEBUG)
Review Comment:
Yes, if there's precedence and reasoning then let's stick with the pattern.
Thanks for the explanation.
--
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]