You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/10/24 21:41:00 UTC

[GitHub] [arrow] westonpace commented on a diff in pull request #14232: ARROW-17458: [C++] Cast between decimal and string

westonpace commented on code in PR #14232:
URL: https://github.com/apache/arrow/pull/14232#discussion_r1003790782


##########
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:
   This seems like an odd condition.  "Not windows OR release mode"?  Is the french locale only unavailable in Windows debug builds?



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org