github-actions[bot] commented on code in PR #25386:
URL: https://github.com/apache/doris/pull/25386#discussion_r1364764778


##########
be/src/vec/functions/function_string.h:
##########
@@ -2423,12 +2423,33 @@ struct MoneyFormatDecimalImpl {
                     frac_part = frac_part * multiplier;
                 }
 
-                StringRef str = MoneyFormat::do_money_format<int64_t, 26>(
+                StringRef str = MoneyFormat::do_money_format<__int128, 53>(

Review Comment:
   warning: 53 is a magic number; consider replacing it with a named constant 
[readability-magic-numbers]
   ```cpp
                   StringRef str = MoneyFormat::do_money_format<__int128, 53>(
                                                                          ^
   ```
   



##########
be/test/vec/data_types/decimal_test.cpp:
##########
@@ -0,0 +1,81 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <gtest/gtest-message.h>
+#include <gtest/gtest-test-part.h>
+#include <gtest/gtest.h>
+
+#include <memory>
+
+#include "gtest/gtest_pred_impl.h"
+#include "runtime/type_limit.h"
+#include "vec/core/types.h"
+namespace doris::vectorized {
+
+TEST(DecimalTest, Decimal256) {
+    // 
9999999999999999999999999999999999999999999999999999999999999999999999999999
+    Decimal256 dec1(type_limit<vectorized::Decimal256>::max());
+    auto des_str = dec1.to_string(10);

Review Comment:
   warning: 10 is a magic number; consider replacing it with a named constant 
[readability-magic-numbers]
   ```cpp
       auto des_str = dec1.to_string(10);
                                     ^
   ```
   



##########
be/test/vec/data_types/decimal_test.cpp:
##########
@@ -0,0 +1,81 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <gtest/gtest-message.h>
+#include <gtest/gtest-test-part.h>
+#include <gtest/gtest.h>
+
+#include <memory>
+
+#include "gtest/gtest_pred_impl.h"
+#include "runtime/type_limit.h"
+#include "vec/core/types.h"
+namespace doris::vectorized {
+
+TEST(DecimalTest, Decimal256) {
+    // 
9999999999999999999999999999999999999999999999999999999999999999999999999999
+    Decimal256 dec1(type_limit<vectorized::Decimal256>::max());
+    auto des_str = dec1.to_string(10);
+    EXPECT_EQ(des_str,
+              
"999999999999999999999999999999999999999999999999999999999999999999.9999999999");
+    des_str = dec1.to_string(0);
+    EXPECT_EQ(des_str,
+              
"9999999999999999999999999999999999999999999999999999999999999999999999999999");
+    des_str = dec1.to_string(76);
+    EXPECT_EQ(des_str,
+              
"0.9999999999999999999999999999999999999999999999999999999999999999999999999999");
+
+    auto dec2 = type_limit<vectorized::Decimal256>::min();
+    des_str = dec2.to_string(10);
+    EXPECT_EQ(des_str,
+              
"-999999999999999999999999999999999999999999999999999999999999999999.9999999999");
+    des_str = dec2.to_string(0);
+    EXPECT_EQ(des_str,
+              
"-9999999999999999999999999999999999999999999999999999999999999999999999999999");
+    des_str = dec2.to_string(76);
+    EXPECT_EQ(des_str,
+              
"-0.9999999999999999999999999999999999999999999999999999999999999999999999999999");
+
+    // plus
+    Decimal256 dec3 = dec1 + dec2;
+    des_str = dec3.to_string(10);

Review Comment:
   warning: 10 is a magic number; consider replacing it with a named constant 
[readability-magic-numbers]
   ```cpp
       des_str = dec3.to_string(10);
                                ^
   ```
   



##########
be/test/vec/data_types/decimal_test.cpp:
##########
@@ -0,0 +1,81 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <gtest/gtest-message.h>
+#include <gtest/gtest-test-part.h>
+#include <gtest/gtest.h>
+
+#include <memory>
+
+#include "gtest/gtest_pred_impl.h"
+#include "runtime/type_limit.h"
+#include "vec/core/types.h"
+namespace doris::vectorized {
+
+TEST(DecimalTest, Decimal256) {

Review Comment:
   warning: all parameters should be named in a function 
[readability-named-parameter]
   
   ```suggestion
   TEST(DecimalTest /*unused*/, Decimal256 /*unused*/) {
   ```
   



##########
be/test/vec/data_types/decimal_test.cpp:
##########
@@ -0,0 +1,81 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <gtest/gtest-message.h>
+#include <gtest/gtest-test-part.h>
+#include <gtest/gtest.h>
+
+#include <memory>
+
+#include "gtest/gtest_pred_impl.h"
+#include "runtime/type_limit.h"
+#include "vec/core/types.h"
+namespace doris::vectorized {
+
+TEST(DecimalTest, Decimal256) {
+    // 
9999999999999999999999999999999999999999999999999999999999999999999999999999
+    Decimal256 dec1(type_limit<vectorized::Decimal256>::max());
+    auto des_str = dec1.to_string(10);
+    EXPECT_EQ(des_str,
+              
"999999999999999999999999999999999999999999999999999999999999999999.9999999999");
+    des_str = dec1.to_string(0);
+    EXPECT_EQ(des_str,
+              
"9999999999999999999999999999999999999999999999999999999999999999999999999999");
+    des_str = dec1.to_string(76);

Review Comment:
   warning: 76 is a magic number; consider replacing it with a named constant 
[readability-magic-numbers]
   ```cpp
       des_str = dec1.to_string(76);
                                ^
   ```
   



##########
be/src/vec/exprs/vexpr.h:
##########
@@ -365,6 +366,13 @@ Status create_texpr_literal_node(const void* data, 
TExprNode* node, int precisio
         decimal_literal.__set_value(origin_value->to_string(scale));
         (*node).__set_decimal_literal(decimal_literal);
         (*node).__set_type(create_type_desc(PrimitiveType::TYPE_DECIMAL128I, 
precision, scale));
+    } else if constexpr (T == TYPE_DECIMAL256) {
+        auto origin_value = reinterpret_cast<const 
vectorized::Decimal<wide::Int256>*>(data);

Review Comment:
   warning: 'auto origin_value' can be declared as 'const auto *origin_value' 
[readability-qualified-auto]
   
   ```suggestion
           const auto *origin_value = reinterpret_cast<const 
vectorized::Decimal<wide::Int256>*>(data);
   ```
   



##########
be/test/vec/data_types/decimal_test.cpp:
##########
@@ -0,0 +1,81 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <gtest/gtest-message.h>

Review Comment:
   warning: 'gtest/gtest-message.h' file not found [clang-diagnostic-error]
   ```cpp
   #include <gtest/gtest-message.h>
            ^
   ```
   



##########
be/test/vec/data_types/decimal_test.cpp:
##########
@@ -0,0 +1,81 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <gtest/gtest-message.h>
+#include <gtest/gtest-test-part.h>
+#include <gtest/gtest.h>
+
+#include <memory>
+
+#include "gtest/gtest_pred_impl.h"
+#include "runtime/type_limit.h"
+#include "vec/core/types.h"
+namespace doris::vectorized {
+
+TEST(DecimalTest, Decimal256) {
+    // 
9999999999999999999999999999999999999999999999999999999999999999999999999999
+    Decimal256 dec1(type_limit<vectorized::Decimal256>::max());
+    auto des_str = dec1.to_string(10);
+    EXPECT_EQ(des_str,
+              
"999999999999999999999999999999999999999999999999999999999999999999.9999999999");
+    des_str = dec1.to_string(0);
+    EXPECT_EQ(des_str,
+              
"9999999999999999999999999999999999999999999999999999999999999999999999999999");
+    des_str = dec1.to_string(76);
+    EXPECT_EQ(des_str,
+              
"0.9999999999999999999999999999999999999999999999999999999999999999999999999999");
+
+    auto dec2 = type_limit<vectorized::Decimal256>::min();
+    des_str = dec2.to_string(10);

Review Comment:
   warning: 10 is a magic number; consider replacing it with a named constant 
[readability-magic-numbers]
   ```cpp
       des_str = dec2.to_string(10);
                                ^
   ```
   



##########
be/test/vec/data_types/decimal_test.cpp:
##########
@@ -0,0 +1,81 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <gtest/gtest-message.h>
+#include <gtest/gtest-test-part.h>
+#include <gtest/gtest.h>
+
+#include <memory>
+
+#include "gtest/gtest_pred_impl.h"
+#include "runtime/type_limit.h"
+#include "vec/core/types.h"
+namespace doris::vectorized {
+
+TEST(DecimalTest, Decimal256) {
+    // 
9999999999999999999999999999999999999999999999999999999999999999999999999999
+    Decimal256 dec1(type_limit<vectorized::Decimal256>::max());
+    auto des_str = dec1.to_string(10);
+    EXPECT_EQ(des_str,
+              
"999999999999999999999999999999999999999999999999999999999999999999.9999999999");
+    des_str = dec1.to_string(0);
+    EXPECT_EQ(des_str,
+              
"9999999999999999999999999999999999999999999999999999999999999999999999999999");
+    des_str = dec1.to_string(76);
+    EXPECT_EQ(des_str,
+              
"0.9999999999999999999999999999999999999999999999999999999999999999999999999999");
+
+    auto dec2 = type_limit<vectorized::Decimal256>::min();
+    des_str = dec2.to_string(10);
+    EXPECT_EQ(des_str,
+              
"-999999999999999999999999999999999999999999999999999999999999999999.9999999999");
+    des_str = dec2.to_string(0);
+    EXPECT_EQ(des_str,
+              
"-9999999999999999999999999999999999999999999999999999999999999999999999999999");
+    des_str = dec2.to_string(76);

Review Comment:
   warning: 76 is a magic number; consider replacing it with a named constant 
[readability-magic-numbers]
   ```cpp
       des_str = dec2.to_string(76);
                                ^
   ```
   



##########
be/test/vec/data_types/decimal_test.cpp:
##########
@@ -0,0 +1,81 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <gtest/gtest-message.h>
+#include <gtest/gtest-test-part.h>
+#include <gtest/gtest.h>
+
+#include <memory>
+
+#include "gtest/gtest_pred_impl.h"
+#include "runtime/type_limit.h"
+#include "vec/core/types.h"
+namespace doris::vectorized {
+
+TEST(DecimalTest, Decimal256) {
+    // 
9999999999999999999999999999999999999999999999999999999999999999999999999999
+    Decimal256 dec1(type_limit<vectorized::Decimal256>::max());
+    auto des_str = dec1.to_string(10);
+    EXPECT_EQ(des_str,
+              
"999999999999999999999999999999999999999999999999999999999999999999.9999999999");
+    des_str = dec1.to_string(0);
+    EXPECT_EQ(des_str,
+              
"9999999999999999999999999999999999999999999999999999999999999999999999999999");
+    des_str = dec1.to_string(76);
+    EXPECT_EQ(des_str,
+              
"0.9999999999999999999999999999999999999999999999999999999999999999999999999999");
+
+    auto dec2 = type_limit<vectorized::Decimal256>::min();
+    des_str = dec2.to_string(10);
+    EXPECT_EQ(des_str,
+              
"-999999999999999999999999999999999999999999999999999999999999999999.9999999999");
+    des_str = dec2.to_string(0);
+    EXPECT_EQ(des_str,
+              
"-9999999999999999999999999999999999999999999999999999999999999999999999999999");
+    des_str = dec2.to_string(76);
+    EXPECT_EQ(des_str,
+              
"-0.9999999999999999999999999999999999999999999999999999999999999999999999999999");
+
+    // plus
+    Decimal256 dec3 = dec1 + dec2;
+    des_str = dec3.to_string(10);
+    EXPECT_EQ(des_str, "0.0000000000");
+    des_str = dec3.to_string(0);
+    EXPECT_EQ(des_str, "0");
+    des_str = dec3.to_string(76);
+    EXPECT_EQ(des_str,
+              
"0.0000000000000000000000000000000000000000000000000000000000000000000000000000");
+
+    // minus
+    dec2 = type_limit<vectorized::Decimal256>::max();
+    dec3 = dec1 - dec2;
+    des_str = dec3.to_string(10);

Review Comment:
   warning: 10 is a magic number; consider replacing it with a named constant 
[readability-magic-numbers]
   ```cpp
       des_str = dec3.to_string(10);
                                ^
   ```
   



##########
be/test/vec/data_types/decimal_test.cpp:
##########
@@ -0,0 +1,81 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <gtest/gtest-message.h>
+#include <gtest/gtest-test-part.h>
+#include <gtest/gtest.h>
+
+#include <memory>
+
+#include "gtest/gtest_pred_impl.h"
+#include "runtime/type_limit.h"
+#include "vec/core/types.h"
+namespace doris::vectorized {
+
+TEST(DecimalTest, Decimal256) {
+    // 
9999999999999999999999999999999999999999999999999999999999999999999999999999
+    Decimal256 dec1(type_limit<vectorized::Decimal256>::max());
+    auto des_str = dec1.to_string(10);
+    EXPECT_EQ(des_str,
+              
"999999999999999999999999999999999999999999999999999999999999999999.9999999999");
+    des_str = dec1.to_string(0);
+    EXPECT_EQ(des_str,
+              
"9999999999999999999999999999999999999999999999999999999999999999999999999999");
+    des_str = dec1.to_string(76);
+    EXPECT_EQ(des_str,
+              
"0.9999999999999999999999999999999999999999999999999999999999999999999999999999");
+
+    auto dec2 = type_limit<vectorized::Decimal256>::min();
+    des_str = dec2.to_string(10);
+    EXPECT_EQ(des_str,
+              
"-999999999999999999999999999999999999999999999999999999999999999999.9999999999");
+    des_str = dec2.to_string(0);
+    EXPECT_EQ(des_str,
+              
"-9999999999999999999999999999999999999999999999999999999999999999999999999999");
+    des_str = dec2.to_string(76);
+    EXPECT_EQ(des_str,
+              
"-0.9999999999999999999999999999999999999999999999999999999999999999999999999999");
+
+    // plus
+    Decimal256 dec3 = dec1 + dec2;
+    des_str = dec3.to_string(10);
+    EXPECT_EQ(des_str, "0.0000000000");
+    des_str = dec3.to_string(0);
+    EXPECT_EQ(des_str, "0");
+    des_str = dec3.to_string(76);

Review Comment:
   warning: 76 is a magic number; consider replacing it with a named constant 
[readability-magic-numbers]
   ```cpp
       des_str = dec3.to_string(76);
                                ^
   ```
   



##########
be/test/vec/data_types/decimal_test.cpp:
##########
@@ -0,0 +1,81 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <gtest/gtest-message.h>
+#include <gtest/gtest-test-part.h>
+#include <gtest/gtest.h>
+
+#include <memory>
+
+#include "gtest/gtest_pred_impl.h"
+#include "runtime/type_limit.h"
+#include "vec/core/types.h"
+namespace doris::vectorized {
+
+TEST(DecimalTest, Decimal256) {
+    // 
9999999999999999999999999999999999999999999999999999999999999999999999999999
+    Decimal256 dec1(type_limit<vectorized::Decimal256>::max());
+    auto des_str = dec1.to_string(10);
+    EXPECT_EQ(des_str,
+              
"999999999999999999999999999999999999999999999999999999999999999999.9999999999");
+    des_str = dec1.to_string(0);
+    EXPECT_EQ(des_str,
+              
"9999999999999999999999999999999999999999999999999999999999999999999999999999");
+    des_str = dec1.to_string(76);
+    EXPECT_EQ(des_str,
+              
"0.9999999999999999999999999999999999999999999999999999999999999999999999999999");
+
+    auto dec2 = type_limit<vectorized::Decimal256>::min();
+    des_str = dec2.to_string(10);
+    EXPECT_EQ(des_str,
+              
"-999999999999999999999999999999999999999999999999999999999999999999.9999999999");
+    des_str = dec2.to_string(0);
+    EXPECT_EQ(des_str,
+              
"-9999999999999999999999999999999999999999999999999999999999999999999999999999");
+    des_str = dec2.to_string(76);
+    EXPECT_EQ(des_str,
+              
"-0.9999999999999999999999999999999999999999999999999999999999999999999999999999");
+
+    // plus
+    Decimal256 dec3 = dec1 + dec2;
+    des_str = dec3.to_string(10);
+    EXPECT_EQ(des_str, "0.0000000000");
+    des_str = dec3.to_string(0);
+    EXPECT_EQ(des_str, "0");
+    des_str = dec3.to_string(76);
+    EXPECT_EQ(des_str,
+              
"0.0000000000000000000000000000000000000000000000000000000000000000000000000000");
+
+    // minus
+    dec2 = type_limit<vectorized::Decimal256>::max();
+    dec3 = dec1 - dec2;
+    des_str = dec3.to_string(10);
+    EXPECT_EQ(des_str, "0.0000000000");
+
+    // multiply
+
+    // divide
+    dec1 = type_limit<vectorized::Decimal256>::max();
+    dec2 = vectorized::Decimal256(10);

Review Comment:
   warning: 10 is a magic number; consider replacing it with a named constant 
[readability-magic-numbers]
   ```cpp
       dec2 = vectorized::Decimal256(10);
                                     ^
   ```
   



-- 
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: commits-unsubscr...@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to