You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2022/12/24 14:09:04 UTC

[doris] branch branch-1.2-lts updated (9d637531e9 -> d4b446d416)

This is an automated email from the ASF dual-hosted git repository.

morningman pushed a change to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git


    from 9d637531e9 [fix](compile) fix compile error caused by `mysql_scan_node.cpp` not being found when enabling `WITH_MYSQL` (#15277)
     new 0bcacfd82b [bug](decimalv3) Fix wrong decimal scale for arithmetic expr (#15316)
     new d4b446d416 [fix](fe)add session variable group_concat_max_len (#15254)

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 docs/en/docs/advanced/variables.md                        |  3 +++
 docs/zh-CN/docs/advanced/variables.md                     |  3 +++
 .../java/org/apache/doris/analysis/ArithmeticExpr.java    | 15 ++++++++++-----
 .../main/java/org/apache/doris/qe/SessionVariable.java    |  5 +++++
 .../datatype_p0/decimalv3/test_arithmetic_expressions.out | 15 +++++++++++++++
 .../correctness_p0/test_show_dummy_variables.groovy       | 10 +++-------
 .../decimalv3/test_arithmetic_expressions.groovy          |  3 +++
 7 files changed, 42 insertions(+), 12 deletions(-)
 copy be/src/runtime/result_writer.cpp => regression-test/suites/correctness_p0/test_show_dummy_variables.groovy (83%)


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


[doris] 01/02: [bug](decimalv3) Fix wrong decimal scale for arithmetic expr (#15316)

Posted by mo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 0bcacfd82b56cbdcfec9e816e351dc7d7379eb85
Author: Gabriel <ga...@gmail.com>
AuthorDate: Sat Dec 24 21:57:46 2022 +0800

    [bug](decimalv3) Fix wrong decimal scale for arithmetic expr (#15316)
---
 .../java/org/apache/doris/analysis/ArithmeticExpr.java    | 15 ++++++++++-----
 .../datatype_p0/decimalv3/test_arithmetic_expressions.out | 15 +++++++++++++++
 .../decimalv3/test_arithmetic_expressions.groovy          |  3 +++
 3 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/ArithmeticExpr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/ArithmeticExpr.java
index 67b5359348..e5502fe635 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ArithmeticExpr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ArithmeticExpr.java
@@ -533,14 +533,14 @@ public class ArithmeticExpr extends Expr {
                     scale = Math.max(t1Scale, t2Scale);
                     precision = Math.max(widthOfIntPart1, widthOfIntPart2) + scale;
                 }
-                if (precision < scale) {
-                    type = castBinaryOp(Type.DOUBLE);
-                    break;
-                }
                 if (precision > ScalarType.MAX_DECIMAL128_PRECISION) {
                     // TODO(gabriel): if precision is bigger than 38?
                     precision = ScalarType.MAX_DECIMAL128_PRECISION;
                 }
+                if (precision < scale) {
+                    type = castBinaryOp(Type.DOUBLE);
+                    break;
+                }
                 type = ScalarType.createDecimalV3Type(precision, scale);
                 if (op == Operator.ADD || op == Operator.SUBTRACT) {
                     if (!Type.matchExactType(type, children.get(0).type)) {
@@ -550,7 +550,12 @@ public class ArithmeticExpr extends Expr {
                         castChild(type, 1);
                     }
                 } else if (op == Operator.DIVIDE && (t2Scale != 0) && t1.isDecimalV3()) {
-                    castChild(ScalarType.createDecimalV3Type(precision, t1Scale + t2Scale), 0);
+                    int targetScale = t1Scale + t2Scale;
+                    if (precision < targetScale) {
+                        type = castBinaryOp(Type.DOUBLE);
+                        break;
+                    }
+                    castChild(ScalarType.createDecimalV3Type(precision, targetScale), 0);
                 }
                 break;
             case INT_DIVIDE:
diff --git a/regression-test/data/datatype_p0/decimalv3/test_arithmetic_expressions.out b/regression-test/data/datatype_p0/decimalv3/test_arithmetic_expressions.out
index a8d9df8d8d..4f68777f2a 100644
--- a/regression-test/data/datatype_p0/decimalv3/test_arithmetic_expressions.out
+++ b/regression-test/data/datatype_p0/decimalv3/test_arithmetic_expressions.out
@@ -17,3 +17,18 @@
 1.440000000000000000000000000000000000
 1.800000000000000000000000000000000000
 
+-- !select --
+1.7160000000000002
+1.8719999999999999
+2.34
+
+-- !select --
+2.9446560000000006
+3.504384
+5.4756
+
+-- !select --
+1.7424
+2.0736
+3.2399999999999998
+
diff --git a/regression-test/suites/datatype_p0/decimalv3/test_arithmetic_expressions.groovy b/regression-test/suites/datatype_p0/decimalv3/test_arithmetic_expressions.groovy
index 44cd313fa0..301d719b15 100644
--- a/regression-test/suites/datatype_p0/decimalv3/test_arithmetic_expressions.groovy
+++ b/regression-test/suites/datatype_p0/decimalv3/test_arithmetic_expressions.groovy
@@ -45,5 +45,8 @@ suite("test_arithmetic_expressions") {
     qt_select "select k1 * k2 from ${table1} order by k1"
     qt_select "select * from (select k1 * k2 from ${table1} union all select k3 from ${table1}) a order by 1"
 
+    qt_select "select k1 * k2 * k3 from ${table1} order by k1"
+    qt_select "select k1 * k2 * k3 * k1 * k2 * k3 from ${table1} order by k1"
+    qt_select "select k1 * k2 / k3 * k1 * k2 * k3 from ${table1} order by k1"
     sql "drop table if exists ${table1}"
 }


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


[doris] 02/02: [fix](fe)add session variable group_concat_max_len (#15254)

Posted by mo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git

commit d4b446d416e40d6978ec8a14b008442b181d5ea4
Author: starocean999 <40...@users.noreply.github.com>
AuthorDate: Sat Dec 24 20:07:14 2022 +0800

    [fix](fe)add session variable group_concat_max_len (#15254)
---
 docs/en/docs/advanced/variables.md                 |  3 +++
 docs/zh-CN/docs/advanced/variables.md              |  3 +++
 .../java/org/apache/doris/qe/SessionVariable.java  |  5 +++++
 .../test_show_dummy_variables.groovy               | 22 ++++++++++++++++++++++
 4 files changed, 33 insertions(+)

diff --git a/docs/en/docs/advanced/variables.md b/docs/en/docs/advanced/variables.md
index b61a175c87..be384315e5 100644
--- a/docs/en/docs/advanced/variables.md
+++ b/docs/en/docs/advanced/variables.md
@@ -553,3 +553,6 @@ Translated with www.DeepL.com/Translator (free version)
 * `validate_password_policy`
 
 	Password strength verification policy. Defaults to `NONE` or `0`, i.e. no verification. Can be set to `STRONG` or `2`. When set to `STRONG` or `2`, when setting a password via the `ALTER USER` or `SET PASSWORD` commands, the password must contain any of "uppercase letters", "lowercase letters", "numbers" and "special characters". 3 items, and the length must be greater than or equal to 8. Special characters include: `~!@#$%^&*()_+|<>,.?/:;'[]{}"`.
+
+* `group_concat_max_len`
+    For compatible purpose. This variable has no effect, just enable some BI tools can query or set this session variable sucessfully.
\ No newline at end of file
diff --git a/docs/zh-CN/docs/advanced/variables.md b/docs/zh-CN/docs/advanced/variables.md
index 39cf63610e..2ca025f825 100644
--- a/docs/zh-CN/docs/advanced/variables.md
+++ b/docs/zh-CN/docs/advanced/variables.md
@@ -542,4 +542,7 @@ SELECT /*+ SET_VAR(query_timeout = 1, enable_partition_cache=true) */ sleep(3);
 * `validate_password_policy`
 
 	密码强度校验策略。默认为 `NONE` 或 `0`,即不做校验。可以设置为 `STRONG` 或 `2`。当设置为 `STRONG` 或 `2` 时,通过 `ALTER USER` 或 `SET PASSWORD` 命令设置密码时,密码必须包含“大写字母”,“小写字母”,“数字”和“特殊字符”中的3项,并且长度必须大于等于8。特殊字符包括:`~!@#$%^&*()_+|<>,.?/:;'[]{}"`。
+
+* `group_concat_max_len`
+    为了兼容某些BI工具能正确获取和设置该变量,变量值实际并没有作用。
 	
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
index b7f30dc7c0..e2e82e91d9 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
@@ -244,6 +244,8 @@ public class SessionVariable implements Serializable, Writable {
     public static final String ENABLE_SHARE_HASH_TABLE_FOR_BROADCAST_JOIN
             = "enable_share_hash_table_for_broadcast_join";
 
+    public static final String GROUP_CONCAT_MAX_LEN = "group_concat_max_len";
+
     // session origin value
     public Map<Field, String> sessionOriginValue = new HashMap<Field, String>();
     // check stmt is or not [select /*+ SET_VAR(...)*/ ...]
@@ -641,6 +643,9 @@ public class SessionVariable implements Serializable, Writable {
     @VariableMgr.VarAttr(name = ENABLE_SHARE_HASH_TABLE_FOR_BROADCAST_JOIN)
     public boolean enableShareHashTableForBroadcastJoin = true;
 
+    @VariableMgr.VarAttr(name = GROUP_CONCAT_MAX_LEN)
+    public int groupConcatMaxLen = 2147483646;
+
     // If this fe is in fuzzy mode, then will use initFuzzyModeVariables to generate some variables,
     // not the default value set in the code.
     public void initFuzzyModeVariables() {
diff --git a/regression-test/suites/correctness_p0/test_show_dummy_variables.groovy b/regression-test/suites/correctness_p0/test_show_dummy_variables.groovy
new file mode 100644
index 0000000000..51f44fb07d
--- /dev/null
+++ b/regression-test/suites/correctness_p0/test_show_dummy_variables.groovy
@@ -0,0 +1,22 @@
+// 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.
+
+suite("test_show_dummy_variables") {
+
+    def ret = sql"""show variables like '%group_concat%';"""
+    assertTrue(ret.toString().contains("group_concat_max_len"))
+}


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