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 2021/08/03 12:09:19 UTC

[GitHub] [arrow] jvictorhuguenin commented on a change in pull request #10718: ARROW-13331: [C++][Gandiva] Add format_number hive function to gandiva

jvictorhuguenin commented on a change in pull request #10718:
URL: https://github.com/apache/arrow/pull/10718#discussion_r681696358



##########
File path: cpp/src/gandiva/precompiled/string_ops_test.cc
##########
@@ -1683,4 +1683,27 @@ TEST(TestStringOps, TestConvertToBigEndian) {
   }
 #endif
 }
+
+TEST(TestStringOps, TestFormatNumberHive) {
+  gandiva::ExecutionContext ctx;
+  uint64_t ctx_ptr = reinterpret_cast<gdv_int64>(&ctx);
+  gdv_int32 out_len = 0;
+  const char* out_str;
+
+  out_str = format_number(ctx_ptr, 10123.4444, 2, &out_len);
+  EXPECT_EQ(std::string(out_str, out_len), "10,123.44");
+
+  out_str = format_number(ctx_ptr, 123456789.1234, 3, &out_len);
+  EXPECT_EQ(std::string(out_str, out_len), "123,456,789.123");
+
+  out_str = format_number(ctx_ptr, 987654321.987654, 0, &out_len);
+  EXPECT_EQ(std::string(out_str, out_len), "987,654,321");
+
+  out_str = format_number(ctx_ptr, 987654321.987654, -1, &out_len);
+  EXPECT_EQ(std::string(out_str, out_len), "");
+  EXPECT_TRUE(ctx.has_error());
+  EXPECT_EQ(ctx.get_error(), "Could not format with negative decimal point");
+

Review comment:
       Add projector tests please




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