You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@doris.apache.org by GitBox <gi...@apache.org> on 2019/04/29 02:57:57 UTC

[GitHub] [incubator-doris] kangkaisen commented on a change in pull request #1064: Add money_format function

kangkaisen commented on a change in pull request #1064: Add money_format function
URL: https://github.com/apache/incubator-doris/pull/1064#discussion_r279228655
 
 

 ##########
 File path: be/src/exprs/string_functions.h
 ##########
 @@ -137,8 +141,37 @@ class StringFunctions {
     static void parse_url_close(
         doris_udf::FunctionContext*,
         doris_udf::FunctionContext::FunctionStateScope);
-};
 
+
+    static doris_udf::StringVal money_format(doris_udf::FunctionContext* context,
+                                                 const doris_udf::DoubleVal& v);
+
+    static doris_udf::StringVal money_format(doris_udf::FunctionContext* context,
+                                                 const doris_udf::DecimalVal& v);
+
+    static doris_udf::StringVal money_format(doris_udf::FunctionContext* context,
+                                                 const doris_udf::BigIntVal& v);
+
+    static doris_udf::StringVal money_format(doris_udf::FunctionContext* context,
+                                                 const doris_udf::LargeIntVal& v);
+
+    struct comma_moneypunct : std::moneypunct<char> {
+        pattern do_pos_format() const override { return {{none, sign, none, value}}; }
+        pattern do_neg_format() const override { return {{none, sign, none, value}}; }
+        int do_frac_digits() const override { return 2; }
+        char_type do_thousands_sep() const override { return ','; }
+        string_type do_grouping() const override { return "\003"; }
+        string_type do_negative_sign() const override { return "-"; }
+    };
+
+    static StringVal do_money_format(FunctionContext *context, const std::string& v) {
+        std::locale comma_locale(std::locale(), new comma_moneypunct());
 
 Review comment:
   OK

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@doris.apache.org
For additional commands, e-mail: dev-help@doris.apache.org