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/07/13 23:53:53 UTC

[GitHub] [arrow] augustoasilva opened a new pull request #10718: ARROW-13331: [C++][Gandiva] Add format_number hive function to gandiva

augustoasilva opened a new pull request #10718:
URL: https://github.com/apache/arrow/pull/10718


   Formats the number X to a format like '#,###,###.##', rounded to D decimal places, and returns the result as a string. If D is 0, the result has no decimal point or fractional part.


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



[GitHub] [arrow] github-actions[bot] commented on pull request #10718: ARROW-13331: [C++][Gandiva] Add format_number hive function to gandiva

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #10718:
URL: https://github.com/apache/arrow/pull/10718#issuecomment-879478708


   https://issues.apache.org/jira/browse/ARROW-13331


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



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

Posted by GitBox <gi...@apache.org>.
augustoasilva commented on pull request #10718:
URL: https://github.com/apache/arrow/pull/10718#issuecomment-879806798


   @jvictorhuguenin could you review this PR?


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



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

Posted by GitBox <gi...@apache.org>.
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



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

Posted by GitBox <gi...@apache.org>.
augustoasilva commented on a change in pull request #10718:
URL: https://github.com/apache/arrow/pull/10718#discussion_r682165568



##########
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:
       Done




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