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 2023/07/19 06:30:26 UTC

[doris] branch branch-1.2-lts updated (171e48865f -> 4e739b5eb8)

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


    omit 171e48865f [fix](planner)only forbid literal value in AnalyticExpr's order by list (#21820)
    omit 9f108c76e4 [tools][ckb] update q29 (#21842)
    omit d1a38d4b57 [fix][branch-1.2](stmt-forward) fix should-be-optional fields in MasterOpService (#21944)
    omit 9df769a462 [fix](in) fix wrong DCHECK of in expr for not nullable column (#21934)
    omit b06177977d [fix](status) fix cmake warning with message 'Manually-specified variables were not used by the project:ENABLE_STACKTRACE' (#21932)
    omit 89bc972d4c [Fix](multi catalog)Fix hive partition value contains special character bug. #21895
    omit c6c2dc20e4 [branch-1.2-lts](cherry-pick) enable strong consistency by syncing max journal… (#21804)
    omit 5d84cc6453 [fix](segment-iterator) fix query result error caused by not handling error codes (#21901)
    omit c8aa346553 [performance](group_concat) avoid extra copy in group_concat (#21880)
    omit 113e9e2340 [fix](merge-on-write) fix wrong result when query with prefix key predicate (#21770)
    omit 66873717c1 [fix](unique-key) fix query results show duplicate key for unique key table after upgrading (#21814)
    omit a2e342839a [feature](profile) backport stream load profile into 1.2-lts (#21784)
    omit eef6a4ab6b [typo](docs) modify the documentation for the bitmap function in 1.2-lts (#21724)
    omit 28b2d4eb85 [Fix](Export) check properties for export (#21768)
    omit 138be9e1ad [Fix](planner) normalize the behavior of from_unixtime() according to 2.0.0 (#21731)
    omit 407ee67744 [fix](compile) fix ColumnArray::update_crcs_with_value (#21781)
    omit 5b5967a0a1 [Improve](array)improve array hash function (#21779)
    omit 666d3f5b06 [fix](catalog) wrong required slot info causing BE crash. (#21702)
    omit cbb90a693c [chore](mv) when create mv failed, show more failed msg (#21726)
    omit 4b9c87d3bf [improvement](bitmap) Use shared_ptr in BitmapValue to avoid deep copying (#19101) (#21271)
    omit ce20cf5e49 [enhancement](mysql) Add have_query_cache variable to be compatible with old mysql client (#21710)
    omit 43d01c2ca9 [fix](jdbc) Added date type filtering pushed down to ClickHouse (#21709)
    omit 02fa51a586 [improvement](timezone) support mixed uppper-lower case of timezone names (#21572) (#21576)
    omit fd6757a274 [fix](function) fix create tablet timeout (#21682)
    omit 87840fa902 [fix](multicatalog) fix protocol of reading data from cosn for hive/iceberg catalog (#21683)
    omit 60c3410f43 [fix](planner)need recalculate nullable info of output slots for join node (#21651)
    omit 818072389f [FIX](array)Fix update hash func array (#21630)
    omit 8c7f5c69b1 [bugfix](nullable) should check nullable info when build output block and print more info when fatal
    omit 823b710885 [Fix](storage)read page cache when seek #21272
    omit 5d1301afff [typo](docs) modify java version to 1.8 (#21538)
    omit cccdd3211e Revert "[Fix](Planner) Set inline view output as non constant after analyze (#21186)" (#21584)
    omit 2a5310e5a1 Delete alter system modify broker related documents in 1.2 (#21582)
    omit e5bed1e6e9 [fix](memtable) change memtable flush error code (#21542)
    omit d7323f0df6 [Fix](Planner) Set inline view output as non constant after analyze (#21186)
    omit 680199e855 [Fix](multi-catalog) Fix hadoop short circuit reading can not enabled in some environments. (#21548)
    omit ee2235a38b [fix](backup) fix show snapshot cauing mysql connection lost (#21520)
    omit 19df0bb2d6 [branch-1.2][Fix](planner)replace limit to -1 if is Long.MAX_VALUE (#21521)
    omit 9a74bec258 [Bug](table-function) fix wrong result when seprator of explode_split size more than one (#18824)
     new 8106524d1e [branch-1.2][Fix](planner)replace limit to -1 if is Long.MAX_VALUE (#21521)
     new 79f81a704a [fix](backup) fix show snapshot cauing mysql connection lost (#21520)
     new 510c928f6c [Fix](multi-catalog) Fix hadoop short circuit reading can not enabled in some environments. (#21548)
     new 180a430c20 [Fix](Planner) Set inline view output as non constant after analyze (#21186)
     new b66f77ad6c [fix](memtable) change memtable flush error code (#21542)
     new 334de9abd7 Delete alter system modify broker related documents in 1.2 (#21582)
     new 7b880f98d0 Revert "[Fix](Planner) Set inline view output as non constant after analyze (#21186)" (#21584)
     new 6637ae4053 [typo](docs) modify java version to 1.8 (#21538)
     new eff5d9157f [Fix](storage)read page cache when seek #21272
     new 87484be8df [bugfix](nullable) should check nullable info when build output block and print more info when fatal
     new f5aac9c546 [FIX](array)Fix update hash func array (#21630)
     new ee47d62aa5 [fix](planner)need recalculate nullable info of output slots for join node (#21651)
     new 545111d27a [fix](multicatalog) fix protocol of reading data from cosn for hive/iceberg catalog (#21683)
     new cd272d40ab [fix](function) fix create tablet timeout (#21682)
     new c2254b98b0 [improvement](timezone) support mixed uppper-lower case of timezone names (#21572) (#21576)
     new f7c90da4b9 [fix](jdbc) Added date type filtering pushed down to ClickHouse (#21709)
     new c700b7c516 [enhancement](mysql) Add have_query_cache variable to be compatible with old mysql client (#21710)
     new 23b964492d [improvement](bitmap) Use shared_ptr in BitmapValue to avoid deep copying (#19101) (#21271)
     new ce112833fc [chore](mv) when create mv failed, show more failed msg (#21726)
     new edeb981536 [fix](catalog) wrong required slot info causing BE crash. (#21702)
     new bb91922f9b [Improve](array)improve array hash function (#21779)
     new bea8f4aba8 [fix](compile) fix ColumnArray::update_crcs_with_value (#21781)
     new 9f27d25d6e [Fix](planner) normalize the behavior of from_unixtime() according to 2.0.0 (#21731)
     new 63f914080a [Fix](Export) check properties for export (#21768)
     new 52fb4cc639 [typo](docs) modify the documentation for the bitmap function in 1.2-lts (#21724)
     new 1aedb81b23 [feature](profile) backport stream load profile into 1.2-lts (#21784)
     new 334007df95 [fix](unique-key) fix query results show duplicate key for unique key table after upgrading (#21814)
     new 0aa24e027a [fix](merge-on-write) fix wrong result when query with prefix key predicate (#21770)
     new 85b077e32c [performance](group_concat) avoid extra copy in group_concat (#21880)
     new b269076f1b [fix](segment-iterator) fix query result error caused by not handling error codes (#21901)
     new dbaf0964de [branch-1.2-lts](cherry-pick) enable strong consistency by syncing max journal… (#21804)
     new 21184bd26b [Fix](multi catalog)Fix hive partition value contains special character bug. #21895
     new 435c519122 [fix](status) fix cmake warning with message 'Manually-specified variables were not used by the project:ENABLE_STACKTRACE' (#21932)
     new 1c8ff29cf0 [fix](in) fix wrong DCHECK of in expr for not nullable column (#21934)
     new f91863c85c [fix][branch-1.2](stmt-forward) fix should-be-optional fields in MasterOpService (#21944)
     new 3b409ea5e4 [tools][ckb] update q29 (#21842)
     new 51faa95eeb [fix](planner)only forbid literal value in AnalyticExpr's order by list (#21820)
     new 4e739b5eb8 [Bug](table-function) fix wrong result when seprator of explode_split size more than one (#18824)

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (171e48865f)
            \
             N -- N -- N   refs/heads/branch-1.2-lts (4e739b5eb8)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 38 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:
 regression-test/conf/regression-conf.groovy        | 52 +++++++++++-----------
 .../sql_functions/table_function/explode_split.out | 25 -----------
 .../table_function/explode_split.groovy            | 37 ---------------
 3 files changed, 26 insertions(+), 88 deletions(-)
 delete mode 100644 regression-test/data/nereids_p0/sql_functions/table_function/explode_split.out
 delete mode 100644 regression-test/suites/nereids_p0/sql_functions/table_function/explode_split.groovy


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


[doris] 22/38: [fix](compile) fix ColumnArray::update_crcs_with_value (#21781)

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 bea8f4aba8a4e781203072d166c0fcec3b2f34b7
Author: Kaijie Chen <ck...@apache.org>
AuthorDate: Thu Jul 13 13:35:50 2023 +0800

    [fix](compile) fix ColumnArray::update_crcs_with_value (#21781)
    
    Fix compile error from #21779
---
 be/src/vec/columns/column_array.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/be/src/vec/columns/column_array.cpp b/be/src/vec/columns/column_array.cpp
index 6a2f40792b..5fb1c079be 100644
--- a/be/src/vec/columns/column_array.cpp
+++ b/be/src/vec/columns/column_array.cpp
@@ -315,12 +315,12 @@ void ColumnArray::update_crcs_with_value(std::vector<uint64_t>& hash, PrimitiveT
         for (size_t i = 0; i < s; ++i) {
             // every row
             if (null_data[i] == 0) {
-                update_crc_with_value(i, hash[i]);
+                update_crc_with_value(i, i + 1, hash[i], nullptr);
             }
         }
     } else {
         for (size_t i = 0; i < s; ++i) {
-            update_crc_with_value(i, hash[i]);
+            update_crc_with_value(i, i + 1, hash[i], nullptr);
         }
     }
 }


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


[doris] 04/38: [Fix](Planner) Set inline view output as non constant after analyze (#21186)

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 180a430c203ef8a20c2a6b283c2fb9f9ee173bee
Author: LiBinfeng <46...@users.noreply.github.com>
AuthorDate: Thu Jul 6 15:37:29 2023 +0800

    [Fix](Planner) Set inline view output as non constant after analyze (#21186)
    
    Problem:
    Select list should be non const when from list have tables or multiple tuples. Or upper query will regard wrong of isConstant
    And make wrong constant folding
    For example: when using nullif funtion with subquery which result in two alternative constant, planner would treat it as constant expr. So analyzer would report an error of order by clause can not be constant
    
    Solusion:
    Change inline view output to non constant, because (select 1 a from table) as view , a in output is no constant when we see
    view.a outside
---
 .../main/java/org/apache/doris/analysis/Expr.java  |  7 +++++
 .../java/org/apache/doris/analysis/SelectStmt.java |  4 +++
 .../org/apache/doris/analysis/QueryStmtTest.java   | 17 ++--------
 .../conditional_functions/test_nullif.out          |  4 +++
 .../conditional_functions/test_nullif.groovy       | 36 ++++++++++++++++++++++
 5 files changed, 54 insertions(+), 14 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java
index abed221866..f2074ae376 100755
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java
@@ -441,6 +441,13 @@ public abstract class Expr extends TreeNode<Expr> implements ParseNode, Cloneabl
         isAnalyzed = true;
     }
 
+    /**
+     * Set the expr isConstant parameter, when select list return it can not be constant
+     */
+    public void setIsConstant(boolean isConstant) {
+        this.isConstant = isConstant;
+    }
+
     protected void computeNumDistinctValues() {
         if (isConstant()) {
             numDistinctValues = 1;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
index d634b5fb62..7c91e33188 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
@@ -453,6 +453,10 @@ public class SelectStmt extends QueryStmt {
                     // Analyze the resultExpr before generating a label to ensure enforcement
                     // of expr child and depth limits (toColumn() label may call toSql()).
                     item.getExpr().analyze(analyzer);
+                    // select list output must not be constant because it is not scalar expression.
+                    if (!fromClause.isEmpty()) {
+                        item.getExpr().setIsConstant(false);
+                    }
                     if (!(item.getExpr() instanceof CaseExpr)
                             && item.getExpr().contains(Predicates.instanceOf(Subquery.class))) {
                         throw new AnalysisException("Subquery is not supported in the select list.");
diff --git a/fe/fe-core/src/test/java/org/apache/doris/analysis/QueryStmtTest.java b/fe/fe-core/src/test/java/org/apache/doris/analysis/QueryStmtTest.java
index 03acde255d..51d2199c53 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/analysis/QueryStmtTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/analysis/QueryStmtTest.java
@@ -210,7 +210,7 @@ public class QueryStmtTest {
         Assert.assertEquals(5, exprsMap.size());
         constMap.clear();
         constMap = getConstantExprMap(exprsMap, analyzer);
-        Assert.assertEquals(2, constMap.size());
+        Assert.assertEquals(1, constMap.size());
 
         // expr in subquery associate with column in grandparent level
         sql = "WITH aa AS\n"
@@ -261,20 +261,9 @@ public class QueryStmtTest {
     @Test
     public void testPutBackExprs() throws Exception {
         ConnectContext ctx = UtFrameUtils.createDefaultCtx();
-        String sql = "SELECT username, @@license, @@time_zone\n"
-                + "FROM db1.table1\n"
-                + "WHERE siteid in\n"
-                + "    (SELECT abs(5+abs(0))+1)\n"
+        String sql = "SELECT @@license, @@time_zone\n"
                 + "UNION\n"
-                + "SELECT CASE\n"
-                + "           WHEN\n"
-                + "                  (SELECT count(*)+abs(8)\n"
-                + "                   FROM db1.table1\n"
-                + "                   WHERE username='helen')>1 THEN 888\n"
-                + "           ELSE 999\n"
-                + "       END AS ccc, @@language, @@storage_engine\n"
-                + "FROM\n"
-                + "  (SELECT curdate()) a;";
+                + "SELECT @@language, @@storage_engine;";
         StatementBase stmt = UtFrameUtils.parseAndAnalyzeStmt(sql, ctx);
         stmt.foldConstant(new Analyzer(ctx.getEnv(), ctx).getExprRewriter());
 
diff --git a/regression-test/data/query_p0/sql_functions/conditional_functions/test_nullif.out b/regression-test/data/query_p0/sql_functions/conditional_functions/test_nullif.out
index f8def44a3d..9675765d6d 100644
--- a/regression-test/data/query_p0/sql_functions/conditional_functions/test_nullif.out
+++ b/regression-test/data/query_p0/sql_functions/conditional_functions/test_nullif.out
@@ -480,3 +480,7 @@ null	12	1	true
 -- !if_nullif28 --
 2020-02-09
 
+-- !if_nullif29 --
+1	1
+2	2
+
diff --git a/regression-test/suites/query_p0/sql_functions/conditional_functions/test_nullif.groovy b/regression-test/suites/query_p0/sql_functions/conditional_functions/test_nullif.groovy
index e754d6d0e8..2f41af96f9 100644
--- a/regression-test/suites/query_p0/sql_functions/conditional_functions/test_nullif.groovy
+++ b/regression-test/suites/query_p0/sql_functions/conditional_functions/test_nullif.groovy
@@ -145,4 +145,40 @@ suite("test_nullif") {
     qt_if_nullif27 """select ifnull(2+3, 2), ifnull((3*1 > 1 || 1>0), 2), ifnull((3*1 > 1 or 1>0), 2),
         ifnull(upper("null"), concat("NUL", "LL"))"""
     qt_if_nullif28 """select ifnull(date(substring("2020-02-09", 1, 1024)), null)"""
+
+    def tableName2 = "testsort"
+
+    sql """ DROP TABLE IF EXISTS ${tableName2}; """
+    sql """
+            CREATE TABLE IF NOT EXISTS ${tableName2} (
+                c_int int NULL COMMENT "",
+                c_pv bitmap BITMAP_UNION NULL COMMENT ""
+            )
+            AGGREGATE KEY(c_int)
+            DISTRIBUTED BY HASH(c_int) BUCKETS 1
+            PROPERTIES (
+              "replication_num" = "1"
+            );
+        """
+    sql """ INSERT INTO ${tableName2} VALUES(1, to_bitmap(1)), (2, to_bitmap(2));"""
+
+    qt_if_nullif29 """
+	select
+	    sortNum,
+	    BITMAP_UNION_COUNT (c.pv) over (ORDER BY sortNum ) totalNum
+	from(
+	select 
+	    ifnull(a.sortNum, b.sortNum) sortNum,
+	    BITMAP_UNION (ifnull(a.c_pv, b.c_pv)) pv
+	from
+	    (select 1 sortNum, c_pv from ${tableName2} t where t.c_int = 1) a
+	full join
+	    (select 2 sortNum, c_pv from ${tableName2} t where t.c_int = 2) b
+	    on a.sortNum = b.sortNum
+	GROUP BY
+	    sortNum
+	ORDER BY
+	    sortNum
+	) c
+	;"""
 }


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


[doris] 12/38: [fix](planner)need recalculate nullable info of output slots for join node (#21651)

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 ee47d62aa567a7ed42dbebb74a92438726ca8534
Author: starocean999 <40...@users.noreply.github.com>
AuthorDate: Mon Jul 10 09:50:43 2023 +0800

    [fix](planner)need recalculate nullable info of output slots for join node (#21651)
    
    pick from master #21650
---
 .../java/org/apache/doris/analysis/ExprSubstitutionMap.java    | 10 ++++++++++
 .../src/main/java/org/apache/doris/planner/JoinNodeBase.java   |  9 +++++++++
 2 files changed, 19 insertions(+)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/ExprSubstitutionMap.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/ExprSubstitutionMap.java
index b88d7a91e9..b483f50285 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ExprSubstitutionMap.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ExprSubstitutionMap.java
@@ -335,4 +335,14 @@ public final class ExprSubstitutionMap {
     public ExprSubstitutionMap clone() {
         return new ExprSubstitutionMap(Expr.cloneList(lhs), Expr.cloneList(rhs));
     }
+
+    public void reCalculateNullableInfoForSlotInRhs() {
+        Preconditions.checkState(lhs.size() == rhs.size(), "lhs and rhs must be same size");
+        for (int i = 0; i < rhs.size(); i++) {
+            if (rhs.get(i) instanceof SlotRef) {
+                ((SlotRef) rhs.get(i)).getDesc().setIsNullable(lhs.get(i).isNullable() 
+                || ((SlotRef) rhs.get(i)).getDesc().getIsNullable());
+            }
+        }
+    }
 }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/JoinNodeBase.java b/fe/fe-core/src/main/java/org/apache/doris/planner/JoinNodeBase.java
index 21ef809f31..3b0f301709 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/JoinNodeBase.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/JoinNodeBase.java
@@ -433,6 +433,15 @@ public abstract class JoinNodeBase extends PlanNode {
         }
         // 5. replace tuple is null expr
         TupleIsNullPredicate.substitueListForTupleIsNull(vSrcToOutputSMap.getLhs(), originTidsToIntermediateTidMap);
+
+        Preconditions.checkState(vSrcToOutputSMap.getLhs().size() == vOutputTupleDesc.getSlots().size());
+        List<Expr> exprs = vSrcToOutputSMap.getLhs();
+        ArrayList<SlotDescriptor> slots = vOutputTupleDesc.getSlots();
+        for (int i = 0; i < slots.size(); i++) {
+            slots.get(i).setIsNullable(exprs.get(i).isNullable() || slots.get(i).getIsNullable());
+        }
+        vSrcToOutputSMap.reCalculateNullableInfoForSlotInRhs();
+        vOutputTupleDesc.computeMemLayout();
     }
 
     protected abstract List<SlotId> computeSlotIdsForJoinConjuncts(Analyzer analyzer);


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


[doris] 19/38: [chore](mv) when create mv failed, show more failed msg (#21726)

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 ce112833fc407296cb96d40df8b3596ed7190c50
Author: zhangstar333 <87...@users.noreply.github.com>
AuthorDate: Tue Jul 11 19:18:28 2023 +0800

    [chore](mv) when create mv failed, show more failed msg (#21726)
    
    when create mv failed, show more failed msg
---
 fe/fe-core/src/main/java/org/apache/doris/alter/RollupJobV2.java | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/RollupJobV2.java b/fe/fe-core/src/main/java/org/apache/doris/alter/RollupJobV2.java
index 3ca0ad2e0e..3914a7bb37 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/alter/RollupJobV2.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/alter/RollupJobV2.java
@@ -459,9 +459,8 @@ public class RollupJobV2 extends AlterJobV2 implements GsonPostProcessable {
                             .getReplicaAllocation(task.getPartitionId()).getTotalReplicaNum();
                     int failedTaskCount = failedAgentTasks.get(task.getTabletId()).size();
                     if (expectSucceedTaskNum - failedTaskCount < expectSucceedTaskNum / 2 + 1) {
-                        throw new AlterCancelException(
-                                "rollup tasks failed on same tablet reach threshold "
-                                        + failedAgentTasks.get(task.getTabletId()));
+                        throw new AlterCancelException("rollup tasks failed on same tablet reach threshold "
+                                + failedAgentTasks.get(task.getTabletId()) + ", reason=" + task.getErrorMsg());
                     }
                 }
             }


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


[doris] 27/38: [fix](unique-key) fix query results show duplicate key for unique key table after upgrading (#21814)

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 334007df95ec226438a09c4f7a36192b44f800d7
Author: Xin Liao <li...@126.com>
AuthorDate: Sat Jul 15 17:17:41 2023 +0800

    [fix](unique-key) fix query results show duplicate key for unique key table after upgrading (#21814)
---
 be/src/olap/rowset/beta_rowset_writer.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/be/src/olap/rowset/beta_rowset_writer.cpp b/be/src/olap/rowset/beta_rowset_writer.cpp
index d2b761b5ed..69a3483905 100644
--- a/be/src/olap/rowset/beta_rowset_writer.cpp
+++ b/be/src/olap/rowset/beta_rowset_writer.cpp
@@ -845,7 +845,10 @@ void BetaRowsetWriter::_build_rowset_meta(std::shared_ptr<RowsetMeta> rowset_met
          ++itr) {
         segments_encoded_key_bounds.push_back(*itr);
     }
-    if (!_is_segment_overlapping(segments_encoded_key_bounds)) {
+    // segment key bounds are empty in old version(before version 1.2.x). So we should not modify
+    // the overlap property when key bounds are empty.
+    if (!segments_encoded_key_bounds.empty() &&
+        !_is_segment_overlapping(segments_encoded_key_bounds)) {
         rowset_meta->set_segments_overlap(NONOVERLAPPING);
     }
 


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


[doris] 23/38: [Fix](planner) normalize the behavior of from_unixtime() according to 2.0.0 (#21731)

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 9f27d25d6e6cd48dde1267d65c255a9f574642e1
Author: mch_ucchi <41...@users.noreply.github.com>
AuthorDate: Thu Jul 13 14:41:31 2023 +0800

    [Fix](planner) normalize the behavior of from_unixtime() according to 2.0.0 (#21731)
    
    if from_unixtime() receive an integer out of int range, the function returns null.
    cherry pick from master branch #21723
---
 .../src/main/java/org/apache/doris/rewrite/FEFunctions.java       | 8 ++++----
 .../src/test/java/org/apache/doris/rewrite/FEFunctionsTest.java   | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/rewrite/FEFunctions.java b/fe/fe-core/src/main/java/org/apache/doris/rewrite/FEFunctions.java
index 9c2023e77f..81cff97b1b 100755
--- a/fe/fe-core/src/main/java/org/apache/doris/rewrite/FEFunctions.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/rewrite/FEFunctions.java
@@ -239,8 +239,8 @@ public class FEFunctions {
     @FEFunction(name = "from_unixtime", argTypes = { "INT" }, returnType = "VARCHAR")
     public static StringLiteral fromUnixTime(LiteralExpr unixTime) throws AnalysisException {
         // if unixTime < 0, we should return null, throw a exception and let BE process
-        if (unixTime.getLongValue() < 0) {
-            throw new AnalysisException("unixtime should larger than zero");
+        if (unixTime.getLongValue() < 0 || unixTime.getLongValue() >= Integer.MAX_VALUE) {
+            throw new AnalysisException("unix timestamp out of range");
         }
         DateLiteral dl = new DateLiteral(unixTime.getLongValue() * 1000, TimeUtils.getTimeZone(),
                 ScalarType.getDefaultDateType(Type.DATETIME));
@@ -250,8 +250,8 @@ public class FEFunctions {
     @FEFunction(name = "from_unixtime", argTypes = { "INT", "VARCHAR" }, returnType = "VARCHAR")
     public static StringLiteral fromUnixTime(LiteralExpr unixTime, StringLiteral fmtLiteral) throws AnalysisException {
         // if unixTime < 0, we should return null, throw a exception and let BE process
-        if (unixTime.getLongValue() < 0) {
-            throw new AnalysisException("unixtime should larger than zero");
+        if (unixTime.getLongValue() < 0 || unixTime.getLongValue() >= Integer.MAX_VALUE) {
+            throw new AnalysisException("unix timestamp out of range");
         }
         DateLiteral dl = new DateLiteral(unixTime.getLongValue() * 1000, TimeUtils.getTimeZone(),
                 ScalarType.getDefaultDateType(Type.DATETIME));
diff --git a/fe/fe-core/src/test/java/org/apache/doris/rewrite/FEFunctionsTest.java b/fe/fe-core/src/test/java/org/apache/doris/rewrite/FEFunctionsTest.java
index 210a8635bc..f7cd440d8f 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/rewrite/FEFunctionsTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/rewrite/FEFunctionsTest.java
@@ -250,7 +250,7 @@ public class FEFunctionsTest {
     @Test
     public void fromUnixTimeTestException() throws AnalysisException {
         expectedEx.expect(AnalysisException.class);
-        expectedEx.expectMessage("unixtime should larger than zero");
+        expectedEx.expectMessage("unix timestamp out of range");
         FEFunctions.fromUnixTime(new IntLiteral(-100));
     }
 


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


[doris] 08/38: [typo](docs) modify java version to 1.8 (#21538)

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 6637ae405305473bc1f3cfaa220b9e01e94be5ed
Author: Euporia <31...@users.noreply.github.com>
AuthorDate: Fri Jul 7 10:21:56 2023 +0800

    [typo](docs) modify java version to 1.8 (#21538)
---
 docs/en/docs/install/source-install/compilation-mac.md    | 4 ++--
 docs/zh-CN/docs/install/source-install/compilation-mac.md | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/docs/en/docs/install/source-install/compilation-mac.md b/docs/en/docs/install/source-install/compilation-mac.md
index 7adea0e339..6754401ff6 100644
--- a/docs/en/docs/install/source-install/compilation-mac.md
+++ b/docs/en/docs/install/source-install/compilation-mac.md
@@ -38,7 +38,7 @@ This topic is about how to compile Doris from source with macOS (both x86_64 and
 1. Use [Homebrew](https://brew.sh/) to install dependencies.
     ```shell
     brew install automake autoconf libtool pkg-config texinfo coreutils gnu-getopt \
-        python@3 cmake ninja ccache bison byacc gettext wget pcre maven llvm@15 openjdk@11 npm
+        python@3 cmake ninja ccache bison byacc gettext wget pcre maven llvm@15 openjdk@8 npm
     ```
 
 2. Compile from source.
@@ -110,4 +110,4 @@ Fail to start BE up. The log shows: `fail to open StorageEngine, res=file descri
 To fix this, please refer to the "Start-up" section above and reset  `file descriptors`.
 
 ### Java Version
-Java 11 is recommended.
+Java 8 is recommended.
diff --git a/docs/zh-CN/docs/install/source-install/compilation-mac.md b/docs/zh-CN/docs/install/source-install/compilation-mac.md
index 2c16cff9db..c9b87b0c3e 100644
--- a/docs/zh-CN/docs/install/source-install/compilation-mac.md
+++ b/docs/zh-CN/docs/install/source-install/compilation-mac.md
@@ -38,7 +38,7 @@ under the License.
 1. 使用[Homebrew](https://brew.sh/)安装依赖
     ```shell
     brew install automake autoconf libtool pkg-config texinfo coreutils gnu-getopt \
-        python@3 cmake ninja ccache bison byacc gettext wget pcre maven llvm@15 openjdk@11 npm
+        python@3 cmake ninja ccache bison byacc gettext wget pcre maven llvm@15 openjdk@8 npm
     ```
 
 2. 编译源码
@@ -109,4 +109,4 @@ under the License.
 参考前面提到的设置`file descriptors`。
 
 ### Java版本
-推荐使用Java 11。
+推荐使用Java 8。


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


[doris] 32/38: [Fix](multi catalog)Fix hive partition value contains special character bug. #21895

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 21184bd26bc2f5b30996403d792a80e0d23b7011
Author: Jibing-Li <64...@users.noreply.github.com>
AuthorDate: Tue Jul 18 18:14:56 2023 +0800

    [Fix](multi catalog)Fix hive partition value contains special character bug. #21895
    
    Hive partition value may contain special characters, such as '/'. This may cause the partition value splitter to get wrong partition values because it use '/' to split partition value. So we need to split the encoded partition name and then decode it to the original value.
---
 .../doris/datasource/hive/HiveMetaStoreCache.java  | 14 ++++--
 .../hive/test_hive_special_char_partition.out      | 51 ++++++++++++++++++++++
 .../hive/test_hive_special_char_partition.groovy   | 51 ++++++++++++++++++++++
 3 files changed, 113 insertions(+), 3 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HiveMetaStoreCache.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HiveMetaStoreCache.java
index 169ed3727b..06a72c112b 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HiveMetaStoreCache.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HiveMetaStoreCache.java
@@ -179,8 +179,9 @@ public class HiveMetaStoreCache {
         Map<Long, List<UniqueId>> idToUniqueIdsMap = Maps.newHashMapWithExpectedSize(partitionNames.size());
         long idx = 0;
         for (String partitionName : partitionNames) {
+            String decodedPartitionName;
             try {
-                partitionName = URLDecoder.decode(partitionName, StandardCharsets.UTF_8.name());
+                decodedPartitionName = URLDecoder.decode(partitionName, StandardCharsets.UTF_8.name());
             } catch (UnsupportedEncodingException e) {
                 // It should not be here
                 throw new RuntimeException(e);
@@ -188,7 +189,7 @@ public class HiveMetaStoreCache {
             long partitionId = idx++;
             ListPartitionItem listPartitionItem = toListPartitionItem(partitionName, key.types);
             idToPartitionItem.put(partitionId, listPartitionItem);
-            partitionNameToIdMap.put(partitionName, partitionId);
+            partitionNameToIdMap.put(decodedPartitionName, partitionId);
         }
 
         Map<UniqueId, Range<PartitionKey>> uidToPartitionRange = null;
@@ -219,7 +220,14 @@ public class HiveMetaStoreCache {
         for (String part : parts) {
             String[] kv = part.split("=");
             Preconditions.checkState(kv.length == 2, partitionName);
-            values.add(new PartitionValue(kv[1], HIVE_DEFAULT_PARTITION.equals(kv[1])));
+            String decodedValue = null;
+            try {
+                decodedValue = URLDecoder.decode(kv[1], StandardCharsets.UTF_8.name());
+            } catch (UnsupportedEncodingException e) {
+                // It should not be here
+                throw new RuntimeException(e);
+            }
+            values.add(new PartitionValue(decodedValue, HIVE_DEFAULT_PARTITION.equals(decodedValue)));
         }
         try {
             PartitionKey key = PartitionKey.createListPartitionKeyWithTypes(values, types);
diff --git a/regression-test/data/external_table_emr_p2/hive/test_hive_special_char_partition.out b/regression-test/data/external_table_emr_p2/hive/test_hive_special_char_partition.out
new file mode 100644
index 0000000000..0bd26b1276
--- /dev/null
+++ b/regression-test/data/external_table_emr_p2/hive/test_hive_special_char_partition.out
@@ -0,0 +1,51 @@
+-- This file is automatically generated. You should know what you did if you want to edit this
+-- !1 --
+name#	2023#01#01
+name1	2023/01/01
+name10	2023<01><01>
+name11	2023\\01\\01
+name12	2023.01.01
+name2	2023 01 01
+name3	2023:01:01
+name4	2023?01?01
+name5	2023=01=01
+name6	2023%01%01
+name8	2023"01"01
+name9	2023'01'01
+
+-- !2 --
+name2
+
+-- !3 --
+name1
+
+-- !4 --
+name4	2023?01?01
+
+-- !5 --
+name12	2023.01.01
+
+-- !6 --
+name10	2023<01><01>
+
+-- !7 --
+name3	2023:01:01
+
+-- !8 --
+name5	2023=01=01
+
+-- !9 --
+name8	2023"01"01
+
+-- !10 --
+name9	2023'01'01
+
+-- !11 --
+name11	2023\\01\\01
+
+-- !12 --
+name6	2023%01%01
+
+-- !13 --
+name#	2023#01#01
+
diff --git a/regression-test/suites/external_table_emr_p2/hive/test_hive_special_char_partition.groovy b/regression-test/suites/external_table_emr_p2/hive/test_hive_special_char_partition.groovy
new file mode 100644
index 0000000000..cb862469f6
--- /dev/null
+++ b/regression-test/suites/external_table_emr_p2/hive/test_hive_special_char_partition.groovy
@@ -0,0 +1,51 @@
+// 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_hive_special_char_partition", "p2") {
+    String enabled = context.config.otherConfigs.get("enableExternalHiveTest")
+    if (enabled != null && enabled.equalsIgnoreCase("true")) {
+        String extHiveHmsHost = context.config.otherConfigs.get("extHiveHmsHost")
+        String extHiveHmsPort = context.config.otherConfigs.get("extHiveHmsPort")
+        String catalog_name = "test_hive_special_char_partition"
+        sql """drop catalog if exists ${catalog_name};"""
+        sql """
+            create catalog if not exists ${catalog_name} properties (
+                'type'='hms',
+                'hadoop.username' = 'hadoop',
+                'hive.metastore.uris' = 'thrift://${extHiveHmsHost}:${extHiveHmsPort}'
+            );
+        """
+        logger.info("catalog " + catalog_name + " created")
+        sql """switch ${catalog_name};"""
+        logger.info("switched to catalog " + catalog_name)
+        sql """use multi_catalog;"""
+        qt_1 "select * from special_character_1_partition order by name"
+        qt_2 "select name from special_character_1_partition where part='2023 01 01'"
+        qt_3 "select name from special_character_1_partition where part='2023/01/01'"
+        qt_4 "select * from special_character_1_partition where part='2023?01?01'"
+        qt_5 "select * from special_character_1_partition where part='2023.01.01'"
+        qt_6 "select * from special_character_1_partition where part='2023<01><01>'"
+        qt_7 "select * from special_character_1_partition where part='2023:01:01'"
+        qt_8 "select * from special_character_1_partition where part='2023=01=01'"
+        qt_9 "select * from special_character_1_partition where part='2023\"01\"01'"
+        qt_10 "select * from special_character_1_partition where part='2023\\'01\\'01'"
+        qt_11 "select * from special_character_1_partition where part='2023\\\\01\\\\01'"
+        qt_12 "select * from special_character_1_partition where part='2023%01%01'"
+        qt_13 "select * from special_character_1_partition where part='2023#01#01'"
+    }
+}
+


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


[doris] 10/38: [bugfix](nullable) should check nullable info when build output block and print more info when fatal

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 87484be8dfdae37c9353acd3c2392bb8fa1ad500
Author: yiguolei <yi...@gmail.com>
AuthorDate: Sat Jul 8 22:33:43 2023 +0800

    [bugfix](nullable) should check nullable info when build output block and print more info when fatal
---
 be/src/vec/exec/join/vjoin_node_base.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/be/src/vec/exec/join/vjoin_node_base.cpp b/be/src/vec/exec/join/vjoin_node_base.cpp
index 0aaf0f1129..7b93f110ff 100644
--- a/be/src/vec/exec/join/vjoin_node_base.cpp
+++ b/be/src/vec/exec/join/vjoin_node_base.cpp
@@ -138,6 +138,11 @@ Status VJoinNodeBase::_build_output_block(Block* origin_block, Block* output_blo
                 RETURN_IF_ERROR(_output_expr_ctxs[i]->execute(origin_block, &result_column_id));
                 auto column_ptr = origin_block->get_by_position(result_column_id)
                                           .column->convert_to_full_column_if_const();
+                // check nullable here, and print more info about plan
+                if (!mutable_columns[i]->is_nullable() && column_ptr->is_nullable()) {
+                    LOG(FATAL) << "to is not nullable while from is nullable, could not copy. i = "
+                               << i << ", exec_node_id = " << _id;
+                }
                 insert_column_datas(mutable_columns[i], *column_ptr, rows);
             }
         }


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


[doris] 15/38: [improvement](timezone) support mixed uppper-lower case of timezone names (#21572) (#21576)

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 c2254b98b07acd6b2e8ef7d8d7d28a7412f11d19
Author: TengJianPing <18...@users.noreply.github.com>
AuthorDate: Tue Jul 11 12:34:42 2023 +0800

    [improvement](timezone) support mixed uppper-lower case of timezone names (#21572) (#21576)
---
 be/src/runtime/exec_env_init.cpp                   |  3 ++
 be/src/util/timezone_utils.cpp                     | 40 ++++++++++++++++++++--
 be/src/util/timezone_utils.h                       | 10 +++++-
 be/test/exprs/timestamp_functions_test.cpp         |  1 +
 be/test/vec/function/function_time_test.cpp        |  3 ++
 .../utils/arrow_column_to_doris_column_test.cpp    |  1 +
 .../datetime_functions/test_date_function.out      | 15 ++++++++
 .../datetime_functions/test_date_function.groovy   |  6 ++++
 8 files changed, 76 insertions(+), 3 deletions(-)

diff --git a/be/src/runtime/exec_env_init.cpp b/be/src/runtime/exec_env_init.cpp
index 4a7ad1d29b..f91233dae0 100644
--- a/be/src/runtime/exec_env_init.cpp
+++ b/be/src/runtime/exec_env_init.cpp
@@ -95,6 +95,9 @@ Status ExecEnv::_init(const std::vector<StorePath>& store_paths) {
     _backend_client_cache = new BackendServiceClientCache(config::max_client_cache_size_per_host);
     _frontend_client_cache = new FrontendServiceClientCache(config::max_client_cache_size_per_host);
     _broker_client_cache = new BrokerServiceClientCache(config::max_client_cache_size_per_host);
+
+    TimezoneUtils::load_timezone_names();
+
     _thread_mgr = new ThreadResourceMgr();
     if (config::doris_enable_scanner_thread_pool_per_disk &&
         config::doris_scanner_thread_pool_thread_num >= store_paths.size() &&
diff --git a/be/src/util/timezone_utils.cpp b/be/src/util/timezone_utils.cpp
index b40a61d129..c22c12b560 100644
--- a/be/src/util/timezone_utils.cpp
+++ b/be/src/util/timezone_utils.cpp
@@ -17,14 +17,46 @@
 //
 
 #include "util/timezone_utils.h"
+#include <cctz/time_zone.h>
+#include <boost/algorithm/string.hpp>
+#include <filesystem>
+#include <string>
 
 namespace doris {
 
 RE2 TimezoneUtils::time_zone_offset_format_reg("^[+-]{1}\\d{2}\\:\\d{2}$");
+std::unordered_map<std::string, std::string> TimezoneUtils::timezone_names_map_;
+bool TimezoneUtils::inited_ = false;
 
 const std::string TimezoneUtils::default_time_zone = "+08:00";
 
+void TimezoneUtils::load_timezone_names() {
+    if (inited_) {
+        return;
+    }
+
+    inited_ = true;
+    std::string path;
+    const char* tzdir = "/usr/share/zoneinfo";
+    char* tzdir_env = std::getenv("TZDIR");
+    if (tzdir_env && *tzdir_env) {
+        tzdir = tzdir_env;
+    }
+    path += tzdir;
+    path += '/';
+
+    auto path_prefix_len = path.size();
+    for (auto const& dir_entry : std::filesystem::recursive_directory_iterator {path}) {
+        if (dir_entry.is_regular_file()) {
+            auto timezone_full_name = dir_entry.path().string().substr(path_prefix_len);
+            timezone_names_map_[boost::algorithm::to_lower_copy(timezone_full_name)] =
+                    timezone_full_name;
+        }
+    }
+}
+
 bool TimezoneUtils::find_cctz_time_zone(const std::string& timezone, cctz::time_zone& ctz) {
+    auto timezone_lower = boost::algorithm::to_lower_copy(timezone);
     re2::StringPiece value;
     if (time_zone_offset_format_reg.Match(timezone, 0, timezone.size(), RE2::UNANCHORED, &value,
                                           1)) {
@@ -44,12 +76,16 @@ bool TimezoneUtils::find_cctz_time_zone(const std::string& timezone, cctz::time_
         offset *= positive ? 1 : -1;
         ctz = cctz::fixed_time_zone(cctz::seconds(offset));
         return true;
-    } else if (timezone == "CST") {
+    } else if (timezone_lower == "cst") {
         // Supports offset and region timezone type, "CST" use here is compatibility purposes.
         ctz = cctz::fixed_time_zone(cctz::seconds(8 * 60 * 60));
         return true;
     } else {
-        return cctz::load_time_zone(timezone, &ctz);
+        auto it = timezone_names_map_.find(timezone_lower);
+        if (it == timezone_names_map_.end()) {
+            return false;
+        }
+        return cctz::load_time_zone(it->second, &ctz);
     }
 }
 
diff --git a/be/src/util/timezone_utils.h b/be/src/util/timezone_utils.h
index 7fbe0ef9e2..ce2fe3ab80 100644
--- a/be/src/util/timezone_utils.h
+++ b/be/src/util/timezone_utils.h
@@ -20,18 +20,26 @@
 
 #include <re2/re2.h>
 
-#include "cctz/time_zone.h"
+#include <unordered_map>
+
+namespace cctz {
+class time_zone;
+} // namespace cctz
 
 namespace doris {
 
 class TimezoneUtils {
 public:
+    static void load_timezone_names();
     static bool find_cctz_time_zone(const std::string& timezone, cctz::time_zone& ctz);
 
 public:
     static const std::string default_time_zone;
 
 private:
+    static bool inited_;
+    static std::unordered_map<std::string, std::string> timezone_names_map_;
+
     // RE2 obj is thread safe
     static RE2 time_zone_offset_format_reg;
 };
diff --git a/be/test/exprs/timestamp_functions_test.cpp b/be/test/exprs/timestamp_functions_test.cpp
index 5193ef71e5..697261e966 100644
--- a/be/test/exprs/timestamp_functions_test.cpp
+++ b/be/test/exprs/timestamp_functions_test.cpp
@@ -40,6 +40,7 @@ public:
     TimestampFunctionsTest() {}
 
     void SetUp() override {
+        TimezoneUtils::load_timezone_names();
         utils = new FunctionUtils();
         ctx = utils->get_fn_ctx();
     }
diff --git a/be/test/vec/function/function_time_test.cpp b/be/test/vec/function/function_time_test.cpp
index 8a68a608b8..07d07ca73f 100644
--- a/be/test/vec/function/function_time_test.cpp
+++ b/be/test/vec/function/function_time_test.cpp
@@ -167,6 +167,7 @@ TEST(VTimestampFunctionsTest, second_test) {
 
 TEST(VTimestampFunctionsTest, from_unix_test) {
     std::string func_name = "from_unixtime";
+    TimezoneUtils::load_timezone_names();
 
     InputTypeSet input_types = {TypeIndex::Int32};
 
@@ -528,6 +529,7 @@ TEST(VTimestampFunctionsTest, makedate_test) {
 }
 
 TEST(VTimestampFunctionsTest, convert_tz_test) {
+    TimezoneUtils::load_timezone_names();
     std::string func_name = "convert_tz";
 
     InputTypeSet input_types = {TypeIndex::DateTime, TypeIndex::String, TypeIndex::String};
@@ -1861,6 +1863,7 @@ TEST(VTimestampFunctionsTest, seconds_sub_v2_test) {
 }
 
 TEST(VTimestampFunctionsTest, convert_tz_v2_test) {
+    TimezoneUtils::load_timezone_names();
     std::string func_name = "convert_tz";
 
     InputTypeSet input_types = {TypeIndex::DateTimeV2, TypeIndex::String, TypeIndex::String};
diff --git a/be/test/vec/utils/arrow_column_to_doris_column_test.cpp b/be/test/vec/utils/arrow_column_to_doris_column_test.cpp
index fda70edd56..e4455fd2e0 100644
--- a/be/test/vec/utils/arrow_column_to_doris_column_test.cpp
+++ b/be/test/vec/utils/arrow_column_to_doris_column_test.cpp
@@ -160,6 +160,7 @@ void test_arrow_to_datetime_column(std::shared_ptr<ArrowType> type, ColumnWithTy
 template <typename ArrowType, typename ColumnType, bool is_nullable>
 void test_datetime(std::shared_ptr<ArrowType> type, const std::vector<std::string>& test_cases,
                    size_t num_elements) {
+    TimezoneUtils::load_timezone_names();
     using ArrowCppType = typename arrow::TypeTraits<ArrowType>::CType;
     size_t counter = 0;
     auto pt = arrow_type_to_primitive_type(type->id());
diff --git a/regression-test/data/query_p0/sql_functions/datetime_functions/test_date_function.out b/regression-test/data/query_p0/sql_functions/datetime_functions/test_date_function.out
index 5ca1401ab5..7cb5586756 100644
--- a/regression-test/data/query_p0/sql_functions/datetime_functions/test_date_function.out
+++ b/regression-test/data/query_p0/sql_functions/datetime_functions/test_date_function.out
@@ -5,6 +5,9 @@
 -- !sql --
 2019-07-31T22:21:03
 
+-- !sql --
+2019-07-31T22:21:03
+
 -- !sql --
 2019-08-01T06:21:03
 
@@ -14,6 +17,18 @@
 -- !sql --
 \N
 
+-- !sql --
+2019-07-31T18:18:27
+
+-- !sql --
+2019-07-31T18:18:27
+
+-- !sql --
+2019-08-01T17:18:27
+
+-- !sql --
+2019-08-01T17:18:27
+
 -- !sql --
 \N
 
diff --git a/regression-test/suites/query_p0/sql_functions/datetime_functions/test_date_function.groovy b/regression-test/suites/query_p0/sql_functions/datetime_functions/test_date_function.groovy
index 78f4a5cba4..2454f76275 100644
--- a/regression-test/suites/query_p0/sql_functions/datetime_functions/test_date_function.groovy
+++ b/regression-test/suites/query_p0/sql_functions/datetime_functions/test_date_function.groovy
@@ -38,6 +38,7 @@ suite("test_date_function") {
     sql """ insert into ${tableName} values ("2019-08-01 13:21:03") """
     // convert_tz
     qt_sql """ SELECT convert_tz(test_datetime, 'Asia/Shanghai', 'America/Los_Angeles') result from ${tableName}; """
+    qt_sql """ SELECT convert_tz(test_datetime, 'Asia/SHANGHAI', 'america/Los_angeles') result from ${tableName}; """
     qt_sql """ SELECT convert_tz(test_datetime, '+08:00', 'America/Los_Angeles') result from ${tableName}; """
 
     qt_sql """ SELECT convert_tz(test_datetime, 'Asia/Shanghai', 'Europe/London') result from ${tableName}; """
@@ -45,6 +46,11 @@ suite("test_date_function") {
 
     qt_sql """ SELECT convert_tz(test_datetime, '+08:00', 'America/London') result from ${tableName}; """
 
+    qt_sql """ select convert_tz("2019-08-01 02:18:27",  'Asia/Shanghai', 'UTC'); """
+    qt_sql """ select convert_tz("2019-08-01 02:18:27",  'Asia/Shanghai', 'UTc'); """
+    qt_sql """ select convert_tz("2019-08-01 02:18:27",  'America/Los_Angeles', 'CST'); """
+    qt_sql """ select convert_tz("2019-08-01 02:18:27",  'America/Los_Angeles', 'cSt'); """
+
     // some invalid date
     qt_sql """ SELECT convert_tz('2022-2-29 13:21:03', '+08:00', 'America/London') result; """
     qt_sql """ SELECT convert_tz('2022-02-29 13:21:03', '+08:00', 'America/London') result; """


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


[doris] 35/38: [fix][branch-1.2](stmt-forward) fix should-be-optional fields in MasterOpService (#21944)

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 f91863c85c6ca598c7fde8189421513f5c9edaf5
Author: Siyang Tang <82...@users.noreply.github.com>
AuthorDate: Tue Jul 18 23:17:25 2023 +0800

    [fix][branch-1.2](stmt-forward) fix should-be-optional fields in MasterOpService (#21944)
    
    * fix-optional-forward-feilds
    
    * fix reviewed
---
 fe/fe-core/src/main/java/org/apache/doris/qe/MasterOpExecutor.java | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/MasterOpExecutor.java b/fe/fe-core/src/main/java/org/apache/doris/qe/MasterOpExecutor.java
index b3ccdf3bbe..5ba69a51c2 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/MasterOpExecutor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/MasterOpExecutor.java
@@ -191,6 +191,10 @@ public class MasterOpExecutor {
         final TMasterOpRequest params = new TMasterOpRequest();
         //node ident
         params.setSyncJournalOnly(true);
+        // just make the protocol happy
+        params.setDb("");
+        params.setUser("");
+        params.setSql("");
         return params;
     }
 


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


[doris] 38/38: [Bug](table-function) fix wrong result when seprator of explode_split size more than one (#18824)

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 4e739b5eb8e6b9b2b44f51f3033a93aed161ac06
Author: morningman <mo...@163.com>
AuthorDate: Wed Jul 19 14:29:56 2023 +0800

    [Bug](table-function) fix wrong result when seprator of explode_split size more than one (#18824)
    
    fix wrong result when seprator of explode_split size more than one
---
 be/src/vec/exprs/table_function/vexplode_split.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/be/src/vec/exprs/table_function/vexplode_split.cpp b/be/src/vec/exprs/table_function/vexplode_split.cpp
index 3401474715..39a3dbd56d 100644
--- a/be/src/vec/exprs/table_function/vexplode_split.cpp
+++ b/be/src/vec/exprs/table_function/vexplode_split.cpp
@@ -89,11 +89,10 @@ Status VExplodeSplitTableFunction::process_row(size_t row_idx) {
                 if (first != second) {
                     output.emplace_back(strv.substr(std::distance(strv.begin(), first),
                                                     std::distance(first, second)));
-                    first = std::next(second);
                 } else {
                     output.emplace_back("", 0);
-                    first = std::next(second, delims.size());
                 }
+                first = std::next(second, delims.size());
 
                 if (second == last) {
                     break;


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


[doris] 14/38: [fix](function) fix create tablet timeout (#21682)

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 cd272d40abdffa0ee2506526f589d268bcd4738b
Author: yujun <yu...@gmail.com>
AuthorDate: Tue Jul 11 09:46:43 2023 +0800

    [fix](function) fix create tablet timeout (#21682)
    
    To get tablet's local size and remote size both need lock the tablet's meta.
    Sometimes the meta lock was locked by other process for a long time (eg, publish version).
    It will cause function 'get root path info' hold the tablet manager's shard lock for a long time too.
    Then it will cause creating tablet could not get the shard lock and finally timeout.
    Let getting tablet's local size/size go out of the scope of tablet manager shard lock.
---
 be/src/http/action/pad_rowset_action.cpp           |  3 ++
 be/src/olap/compaction.cpp                         |  1 +
 be/src/olap/schema_change.cpp                      |  5 +++
 be/src/olap/tablet.cpp                             |  6 ++++
 be/src/olap/tablet.h                               |  2 ++
 be/src/olap/tablet_manager.cpp                     | 38 +++++++++-------------
 be/src/olap/tablet_manager.h                       |  3 +-
 be/src/olap/task/engine_clone_task.cpp             |  2 ++
 be/src/util/trace.h                                | 29 +++++++++++++++++
 .../apache/doris/datasource/InternalCatalog.java   |  2 +-
 10 files changed, 67 insertions(+), 24 deletions(-)

diff --git a/be/src/http/action/pad_rowset_action.cpp b/be/src/http/action/pad_rowset_action.cpp
index df2721f50b..1b16e3f98d 100644
--- a/be/src/http/action/pad_rowset_action.cpp
+++ b/be/src/http/action/pad_rowset_action.cpp
@@ -25,6 +25,8 @@
 #include "olap/rowset/beta_rowset_writer.h"
 #include "olap/rowset/rowset.h"
 #include "olap/storage_engine.h"
+#include "util/time.h"
+#include "util/trace.h"
 
 namespace doris {
 
@@ -95,6 +97,7 @@ Status PadRowsetAction::_pad_rowset(TabletSharedPtr tablet, const Version& versi
     std::vector<RowsetSharedPtr> to_delete;
     {
         std::unique_lock wlock(tablet->get_header_lock());
+        SCOPED_SIMPLE_TRACE_IF_TIMEOUT(TRACE_TABLET_LOCK_THRESHOLD);
         tablet->modify_rowsets(to_add, to_delete);
         tablet->save_meta();
     }
diff --git a/be/src/olap/compaction.cpp b/be/src/olap/compaction.cpp
index b9e9754030..8fd87a0e5f 100644
--- a/be/src/olap/compaction.cpp
+++ b/be/src/olap/compaction.cpp
@@ -467,6 +467,7 @@ Status Compaction::modify_rowsets(const Merger::Statistics* stats) {
         {
             std::lock_guard<std::mutex> wrlock_(_tablet->get_rowset_update_lock());
             std::lock_guard<std::shared_mutex> wrlock(_tablet->get_header_lock());
+            SCOPED_SIMPLE_TRACE_IF_TIMEOUT(TRACE_TABLET_LOCK_THRESHOLD);
 
             // Convert the delete bitmap of the input rowsets to output rowset for
             // incremental data.
diff --git a/be/src/olap/schema_change.cpp b/be/src/olap/schema_change.cpp
index 2ceff6f7c6..dd81df84d3 100644
--- a/be/src/olap/schema_change.cpp
+++ b/be/src/olap/schema_change.cpp
@@ -32,6 +32,7 @@
 #include "olap/wrapper_field.h"
 #include "runtime/memory/mem_tracker.h"
 #include "util/defer_op.h"
+#include "util/trace.h"
 #include "vec/aggregate_functions/aggregate_function.h"
 #include "vec/aggregate_functions/aggregate_function_reader.h"
 #include "vec/aggregate_functions/aggregate_function_simple_factory.h"
@@ -1846,6 +1847,7 @@ Status SchemaChangeHandler::_do_process_alter_tablet_v2(const TAlterTabletReqV2&
         std::lock_guard<std::mutex> base_tablet_lock(base_tablet->get_push_lock());
         std::lock_guard<std::mutex> new_tablet_lock(new_tablet->get_push_lock());
         std::lock_guard<std::shared_mutex> base_tablet_wlock(base_tablet->get_header_lock());
+        SCOPED_SIMPLE_TRACE_IF_TIMEOUT(TRACE_TABLET_LOCK_THRESHOLD);
         std::lock_guard<std::shared_mutex> new_tablet_wlock(new_tablet->get_header_lock());
 
         do {
@@ -2064,6 +2066,7 @@ Status SchemaChangeHandler::_do_process_alter_tablet_v2(const TAlterTabletReqV2&
             // step 3
             std::lock_guard<std::mutex> rwlock(new_tablet->get_rowset_update_lock());
             std::lock_guard<std::shared_mutex> new_wlock(new_tablet->get_header_lock());
+            SCOPED_SIMPLE_TRACE_IF_TIMEOUT(TRACE_TABLET_LOCK_THRESHOLD);
             int64_t new_max_version = new_tablet->max_version().second;
             rowsets.clear();
             if (max_version < new_max_version) {
@@ -2094,6 +2097,7 @@ Status SchemaChangeHandler::_do_process_alter_tablet_v2(const TAlterTabletReqV2&
         } else {
             // set state to ready
             std::lock_guard<std::shared_mutex> new_wlock(new_tablet->get_header_lock());
+            SCOPED_SIMPLE_TRACE_IF_TIMEOUT(TRACE_TABLET_LOCK_THRESHOLD);
             res = new_tablet->set_tablet_state(TabletState::TABLET_RUNNING);
             if (!res) {
                 break;
@@ -2171,6 +2175,7 @@ Status SchemaChangeHandler::_convert_historical_rowsets(const SchemaChangeParams
         {
             // save tablet meta here because rowset meta is not saved during add rowset
             std::lock_guard<std::shared_mutex> new_wlock(sc_params.new_tablet->get_header_lock());
+            SCOPED_SIMPLE_TRACE_IF_TIMEOUT(TRACE_TABLET_LOCK_THRESHOLD);
             sc_params.new_tablet->save_meta();
         }
         if (res) {
diff --git a/be/src/olap/tablet.cpp b/be/src/olap/tablet.cpp
index ce1b14f8a1..968b6ad9d4 100644
--- a/be/src/olap/tablet.cpp
+++ b/be/src/olap/tablet.cpp
@@ -68,6 +68,7 @@
 
 namespace doris {
 using namespace ErrorCode;
+using namespace std::chrono_literals;
 
 using std::pair;
 using std::nothrow;
@@ -75,6 +76,8 @@ using std::sort;
 using std::string;
 using std::vector;
 
+const std::chrono::seconds TRACE_TABLET_LOCK_THRESHOLD = 10s;
+
 DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(flush_bytes, MetricUnit::BYTES);
 DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(flush_finish_count, MetricUnit::OPERATIONS);
 
@@ -300,6 +303,7 @@ Status Tablet::revise_tablet_meta(const std::vector<RowsetMetaSharedPtr>& rowset
 Status Tablet::add_rowset(RowsetSharedPtr rowset) {
     DCHECK(rowset != nullptr);
     std::lock_guard<std::shared_mutex> wrlock(_meta_lock);
+    SCOPED_SIMPLE_TRACE_IF_TIMEOUT(TRACE_TABLET_LOCK_THRESHOLD);
     // If the rowset already exist, just return directly.  The rowset_id is an unique-id,
     // we can use it to check this situation.
     if (_contains_rowset(rowset->rowset_id())) {
@@ -535,6 +539,7 @@ void Tablet::_delete_stale_rowset_by_version(const Version& version) {
 void Tablet::delete_expired_stale_rowset() {
     int64_t now = UnixSeconds();
     std::lock_guard<std::shared_mutex> wrlock(_meta_lock);
+    SCOPED_SIMPLE_TRACE_IF_TIMEOUT(TRACE_TABLET_LOCK_THRESHOLD);
     // Compute the end time to delete rowsets, when a expired rowset createtime less then this time, it will be deleted.
     double expired_stale_sweep_endtime =
             ::difftime(now, config::tablet_rowset_stale_sweep_time_sec);
@@ -972,6 +977,7 @@ void Tablet::_max_continuous_version_from_beginning_unlocked(Version* version, V
 
 void Tablet::calculate_cumulative_point() {
     std::lock_guard<std::shared_mutex> wrlock(_meta_lock);
+    SCOPED_SIMPLE_TRACE_IF_TIMEOUT(TRACE_TABLET_LOCK_THRESHOLD);
     int64_t ret_cumulative_point;
     _cumulative_compaction_policy->calculate_cumulative_point(
             this, _tablet_meta->all_rs_metas(), _cumulative_point, &ret_cumulative_point);
diff --git a/be/src/olap/tablet.h b/be/src/olap/tablet.h
index d34597323a..15e17223c3 100644
--- a/be/src/olap/tablet.h
+++ b/be/src/olap/tablet.h
@@ -62,6 +62,8 @@ using TabletSharedPtr = std::shared_ptr<Tablet>;
 
 enum TabletStorageType { STORAGE_TYPE_LOCAL, STORAGE_TYPE_REMOTE, STORAGE_TYPE_REMOTE_AND_LOCAL };
 
+extern const std::chrono::seconds TRACE_TABLET_LOCK_THRESHOLD;
+
 class Tablet : public BaseTablet {
 public:
     static TabletSharedPtr create_tablet_from_meta(TabletMetaSharedPtr tablet_meta,
diff --git a/be/src/olap/tablet_manager.cpp b/be/src/olap/tablet_manager.cpp
index fa7c25e9c4..5f2bd1b5c0 100644
--- a/be/src/olap/tablet_manager.cpp
+++ b/be/src/olap/tablet_manager.cpp
@@ -473,6 +473,7 @@ Status TabletManager::_drop_tablet_unlocked(TTabletId tablet_id, TReplicaId repl
     if (!keep_files) {
         // drop tablet will update tablet meta, should lock
         std::lock_guard<std::shared_mutex> wrlock(to_drop_tablet->get_header_lock());
+        SCOPED_SIMPLE_TRACE_IF_TIMEOUT(TRACE_TABLET_LOCK_THRESHOLD);
         LOG(INFO) << "set tablet to shutdown state and remove it from memory. "
                   << "tablet_id=" << tablet_id << ", tablet_path=" << to_drop_tablet->tablet_path();
         // NOTE: has to update tablet here, but must not update tablet meta directly.
@@ -583,18 +584,14 @@ TabletSharedPtr TabletManager::get_tablet(TTabletId tablet_id, TabletUid tablet_
     return nullptr;
 }
 
-std::vector<TabletSharedPtr> TabletManager::get_all_tablet() {
+std::vector<TabletSharedPtr> TabletManager::get_all_tablet(std::function<bool(Tablet*)>&& filter) {
     std::vector<TabletSharedPtr> res;
     for (const auto& tablets_shard : _tablets_shards) {
         std::shared_lock rdlock(tablets_shard.lock);
-        for (const auto& tablet_map : tablets_shard.tablet_map) {
-            // these are tablets which is not deleted
-            TabletSharedPtr tablet = tablet_map.second;
-            if (!tablet->is_used()) {
-                LOG(WARNING) << "tablet cannot be used. tablet=" << tablet->tablet_id();
-                continue;
+        for (auto& [id, tablet] : tablets_shard.tablet_map) {
+            if (filter(tablet.get())) {
+                res.emplace_back(tablet);
             }
-            res.emplace_back(tablet);
         }
     }
     return res;
@@ -1096,20 +1093,17 @@ void TabletManager::update_root_path_info(std::map<string, DataDirInfo>* path_ma
                                           size_t* tablet_count) {
     DCHECK(tablet_count);
     *tablet_count = 0;
-    for (const auto& tablets_shard : _tablets_shards) {
-        std::shared_lock rdlock(tablets_shard.lock);
-        for (const auto& item : tablets_shard.tablet_map) {
-            TabletSharedPtr tablet = item.second;
-            ++(*tablet_count);
-            auto iter = path_map->find(tablet->data_dir()->path());
-            if (iter == path_map->end()) {
-                continue;
-            }
-            if (iter->second.is_used) {
-                iter->second.local_used_capacity += tablet->tablet_local_size();
-                iter->second.remote_used_capacity += tablet->tablet_remote_size();
-            }
-        }
+    auto filter = [path_map, tablet_count](Tablet* t) -> bool {
+        ++(*tablet_count);
+        auto iter = path_map->find(t->data_dir()->path());
+        return iter != path_map->end() && iter->second.is_used;
+    };
+
+    auto tablets = get_all_tablet(filter);
+    for (const auto& tablet : tablets) {
+        auto& data_dir_info = (*path_map)[tablet->data_dir()->path()];
+        data_dir_info.local_used_capacity += tablet->tablet_local_size();
+        data_dir_info.remote_used_capacity += tablet->tablet_remote_size();
     }
 }
 
diff --git a/be/src/olap/tablet_manager.h b/be/src/olap/tablet_manager.h
index 667013d268..378ff499ac 100644
--- a/be/src/olap/tablet_manager.h
+++ b/be/src/olap/tablet_manager.h
@@ -78,7 +78,8 @@ public:
     TabletSharedPtr get_tablet(TTabletId tablet_id, TabletUid tablet_uid,
                                bool include_deleted = false, std::string* err = nullptr);
 
-    std::vector<TabletSharedPtr> get_all_tablet();
+    std::vector<TabletSharedPtr> get_all_tablet(std::function<bool(Tablet*)>&& filter =
+                                                        [](Tablet* t) { return t->is_used(); });
 
     uint64_t get_rowset_nums();
     uint64_t get_segment_nums();
diff --git a/be/src/olap/task/engine_clone_task.cpp b/be/src/olap/task/engine_clone_task.cpp
index 5c8c2f8070..9352c7a0ce 100644
--- a/be/src/olap/task/engine_clone_task.cpp
+++ b/be/src/olap/task/engine_clone_task.cpp
@@ -34,6 +34,7 @@
 #include "runtime/thread_context.h"
 #include "util/defer_op.h"
 #include "util/thrift_rpc_helper.h"
+#include "util/trace.h"
 
 using std::set;
 using std::stringstream;
@@ -466,6 +467,7 @@ Status EngineCloneTask::_finish_clone(Tablet* tablet, const std::string& clone_d
     std::lock_guard<std::mutex> push_lock(tablet->get_push_lock());
     std::lock_guard<std::mutex> rwlock(tablet->get_rowset_update_lock());
     std::lock_guard<std::shared_mutex> wrlock(tablet->get_header_lock());
+    SCOPED_SIMPLE_TRACE_IF_TIMEOUT(TRACE_TABLET_LOCK_THRESHOLD);
     // check clone dir existed
     if (!FileUtils::check_exist(clone_dir)) {
         return Status::InternalError("clone dir not existed. clone_dir={}", clone_dir);
diff --git a/be/src/util/trace.h b/be/src/util/trace.h
index 40c6ba265f..7fe0c9e0c2 100644
--- a/be/src/util/trace.h
+++ b/be/src/util/trace.h
@@ -18,18 +18,21 @@
 
 #include <rapidjson/writer.h>
 
+#include <chrono>
 #include <iosfwd>
 #include <memory>
 #include <string>
 #include <utility>
 #include <vector>
 
+#include "common/logging.h"
 #include "gutil/macros.h"
 #include "gutil/ref_counted.h"
 #include "gutil/strings/stringpiece.h"
 #include "gutil/strings/substitute.h"
 #include "gutil/threading/thread_collision_warner.h"
 #include "gutil/walltime.h"
+#include "util/scoped_cleanup.h"
 #include "util/spinlock.h"
 #include "util/trace_metrics.h"
 
@@ -112,6 +115,32 @@ class Trace;
         }                                          \
     }()
 
+// If this scope times out, make a simple trace.
+// It will log the cost time only.
+// Timeout is chrono duration struct, eg: 5ms, 100 * 1s.
+#define SCOPED_SIMPLE_TRACE_IF_TIMEOUT(timeout) \
+    SCOPED_SIMPLE_TRACE_TO_STREAM_IF_TIMEOUT(timeout, LOG(WARNING))
+
+// If this scope times out, then put simple trace to the stream.
+// Timeout is chrono duration struct, eg: 5ms, 100 * 1s.
+// For example:
+//
+//    std::string tag = "[foo]";
+//    SCOPED_SIMPLE_TRACE_TO_STREAM_IF_TIMEOUT(5s, LOG(INFO) << tag);
+//
+#define SCOPED_SIMPLE_TRACE_TO_STREAM_IF_TIMEOUT(timeout, stream)                       \
+    using namespace std::chrono_literals;                                               \
+    auto VARNAME_LINENUM(scoped_simple_trace) = doris::MonotonicMicros();               \
+    SCOPED_CLEANUP({                                                                    \
+        auto VARNAME_LINENUM(timeout_us) =                                              \
+                std::chrono::duration_cast<std::chrono::microseconds>(timeout).count(); \
+        auto VARNAME_LINENUM(cost_us) =                                                 \
+                doris::MonotonicMicros() - VARNAME_LINENUM(scoped_simple_trace);        \
+        if (VARNAME_LINENUM(cost_us) >= VARNAME_LINENUM(timeout_us)) {                  \
+            stream << "Simple trace cost(us): " << VARNAME_LINENUM(cost_us);            \
+        }                                                                               \
+    })
+
 namespace doris {
 
 struct TraceEntry;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java
index 8a93277bf5..ca24af08eb 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java
@@ -1763,7 +1763,7 @@ public class InternalCatalog implements CatalogIf<Database> {
             }
 
             if (!ok || !countDownLatch.getStatus().ok()) {
-                errMsg = "Failed to create partition[" + partitionName + "]. Timeout.";
+                errMsg = "Failed to create partition[" + partitionName + "]. Timeout:" + (timeout / 1000) + " seconds.";
                 // clear tasks
                 AgentTaskQueue.removeBatchTask(batchTask, TTaskType.CREATE);
 


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


[doris] 25/38: [typo](docs) modify the documentation for the bitmap function in 1.2-lts (#21724)

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 52fb4cc6393685e2679a4e4afb260d5e0cf3b034
Author: Euporia <31...@users.noreply.github.com>
AuthorDate: Fri Jul 14 18:48:20 2023 +0800

    [typo](docs) modify the documentation for the bitmap function in 1.2-lts (#21724)
---
 .../sql-functions/bitmap-functions/bitmap_and.md   | 15 +++++++++----
 .../bitmap-functions/bitmap_and_not.md             | 21 +++++++++++++++++
 .../sql-functions/bitmap-functions/bitmap_empty.md |  7 ++++++
 .../bitmap-functions/bitmap_has_all.md             | 26 +++++++++++-----------
 .../bitmap-functions/bitmap_has_any.md             | 26 +++++++++++-----------
 .../bitmap-functions/bitmap_hash64.md              | 12 +++++-----
 .../sql-functions/bitmap-functions/bitmap_not.md   | 14 ++++++------
 .../sql-functions/bitmap-functions/bitmap_or.md    | 25 +++++++++++++--------
 .../sql-functions/bitmap-functions/bitmap_and.md   | 15 +++++++++----
 .../bitmap-functions/bitmap_and_not.md             | 21 +++++++++++++++++
 .../sql-functions/bitmap-functions/bitmap_empty.md |  7 ++++++
 .../bitmap-functions/bitmap_has_all.md             | 26 +++++++++++-----------
 .../bitmap-functions/bitmap_has_any.md             | 26 +++++++++++-----------
 .../bitmap-functions/bitmap_hash64.md              | 12 +++++-----
 .../sql-functions/bitmap-functions/bitmap_not.md   | 20 ++++++++---------
 .../sql-functions/bitmap-functions/bitmap_or.md    | 25 +++++++++++++--------
 16 files changed, 191 insertions(+), 107 deletions(-)

diff --git a/docs/en/docs/sql-manual/sql-functions/bitmap-functions/bitmap_and.md b/docs/en/docs/sql-manual/sql-functions/bitmap-functions/bitmap_and.md
index a64a52b570..7cfdcec0d0 100644
--- a/docs/en/docs/sql-manual/sql-functions/bitmap-functions/bitmap_and.md
+++ b/docs/en/docs/sql-manual/sql-functions/bitmap-functions/bitmap_and.md
@@ -42,6 +42,13 @@ mysql> select bitmap_count(bitmap_and(to_bitmap(1), to_bitmap(2))) cnt;
 |    0 |
 +------+
 
+mysql> select bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(2)));
++----------------------------------------------------------+
+| bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(2))) |
++----------------------------------------------------------+
+|                                                          |
++----------------------------------------------------------+
+
 mysql> select bitmap_count(bitmap_and(to_bitmap(1), to_bitmap(1))) cnt;
 +------+
 | cnt  |
@@ -49,28 +56,28 @@ mysql> select bitmap_count(bitmap_and(to_bitmap(1), to_bitmap(1))) cnt;
 |    1 |
 +------+
 
-MySQL> select bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(1)));
+mysql> select bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(1)));
 +----------------------------------------------------------+
 | bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(1))) |
 +----------------------------------------------------------+
 | 1                                                        |
 +----------------------------------------------------------+
 
-MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5')));
+mysql> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5')));
 +-----------------------------------------------------------------------------------------------------------------------+
 | bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))) |
 +-----------------------------------------------------------------------------------------------------------------------+
 | 1,2                                                                                                                   |
 +-----------------------------------------------------------------------------------------------------------------------+
 
-MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty()));
+mysql> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty()));
 +---------------------------------------------------------------------------------------------------------------------------------------+
 | bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), bitmap_empty())) |
 +---------------------------------------------------------------------------------------------------------------------------------------+
 |                                                                                                                                       |
 +---------------------------------------------------------------------------------------------------------------------------------------+
 
-MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),NULL));
+mysql> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),NULL));
 +-----------------------------------------------------------------------------------------------------------------------------+
 | bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL)) |
 +-----------------------------------------------------------------------------------------------------------------------------+
diff --git a/docs/en/docs/sql-manual/sql-functions/bitmap-functions/bitmap_and_not.md b/docs/en/docs/sql-manual/sql-functions/bitmap-functions/bitmap_and_not.md
index e370ce90b3..b0f13dced1 100644
--- a/docs/en/docs/sql-manual/sql-functions/bitmap-functions/bitmap_and_not.md
+++ b/docs/en/docs/sql-manual/sql-functions/bitmap-functions/bitmap_and_not.md
@@ -41,6 +41,27 @@ mysql> select bitmap_count(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_fro
 +------+
 |    2 |
 +------+
+
+mysql> select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5')));
++--------------------------------------------------------------------------------------------+
+| bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5'))) |
++--------------------------------------------------------------------------------------------+
+| 1,2                                                                                        |
++--------------------------------------------------------------------------------------------+
+
+mysql> select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_empty())) ;
++-------------------------------------------------------------------------------+
+| bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'), bitmap_empty())) |
++-------------------------------------------------------------------------------+
+| 1,2,3                                                                         |
++-------------------------------------------------------------------------------+
+
+mysql> select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),NULL));
++---------------------------------------------------------------------+
+| bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'), NULL)) |
++---------------------------------------------------------------------+
+| NULL                                                                |
++---------------------------------------------------------------------+
 ```
 
 ### keywords
diff --git a/docs/en/docs/sql-manual/sql-functions/bitmap-functions/bitmap_empty.md b/docs/en/docs/sql-manual/sql-functions/bitmap-functions/bitmap_empty.md
index 6c5a90ccea..a8b4bbdcc1 100644
--- a/docs/en/docs/sql-manual/sql-functions/bitmap-functions/bitmap_empty.md
+++ b/docs/en/docs/sql-manual/sql-functions/bitmap-functions/bitmap_empty.md
@@ -45,6 +45,13 @@ mysql> select bitmap_count(bitmap_empty());
 +------------------------------+
 |                            0 |
 +------------------------------+
+
+mysql> select bitmap_to_string(bitmap_empty());
++----------------------------------+
+| bitmap_to_string(bitmap_empty()) |
++----------------------------------+
+|                                  |
++----------------------------------+
 ```
 
 ### keywords
diff --git a/docs/en/docs/sql-manual/sql-functions/bitmap-functions/bitmap_has_all.md b/docs/en/docs/sql-manual/sql-functions/bitmap-functions/bitmap_has_all.md
index 7087abf531..a8dc6b19b5 100644
--- a/docs/en/docs/sql-manual/sql-functions/bitmap-functions/bitmap_has_all.md
+++ b/docs/en/docs/sql-manual/sql-functions/bitmap-functions/bitmap_has_all.md
@@ -36,19 +36,19 @@ Returns true if the second bitmap contains an empty element.
 ### example
 
 ```
-mysql> select bitmap_has_all(bitmap_from_string("0, 1, 2"), bitmap_from_string("1, 2")) cnt;
-+------+
-| cnt  |
-+------+
-|    1 |
-+------+
-
-mysql> select bitmap_has_all(bitmap_empty(), bitmap_from_string("1, 2")) cnt;
-+------+
-| cnt  |
-+------+
-|    0 |
-+------+
+mysql> select bitmap_has_all(bitmap_from_string("0, 1, 2"), bitmap_from_string("1, 2"));
++---------------------------------------------------------------------------+
+| bitmap_has_all(bitmap_from_string('0, 1, 2'), bitmap_from_string('1, 2')) |
++---------------------------------------------------------------------------+
+|                                                                         1 |
++---------------------------------------------------------------------------+
+
+mysql> select bitmap_has_all(bitmap_empty(), bitmap_from_string("1, 2"));
++------------------------------------------------------------+
+| bitmap_has_all(bitmap_empty(), bitmap_from_string('1, 2')) |
++------------------------------------------------------------+
+|                                                          0 |
++------------------------------------------------------------+
 ```
 
 ### keywords
diff --git a/docs/en/docs/sql-manual/sql-functions/bitmap-functions/bitmap_has_any.md b/docs/en/docs/sql-manual/sql-functions/bitmap-functions/bitmap_has_any.md
index 4e47b6f343..0466aeb322 100644
--- a/docs/en/docs/sql-manual/sql-functions/bitmap-functions/bitmap_has_any.md
+++ b/docs/en/docs/sql-manual/sql-functions/bitmap-functions/bitmap_has_any.md
@@ -35,19 +35,19 @@ Calculate whether there are intersecting elements in the two Bitmap columns. The
 ### example
 
 ```
-mysql> select bitmap_has_any(to_bitmap(1),to_bitmap(2)) cnt;
-+------+
-| cnt  |
-+------+
-|    0 |
-+------+
-
-mysql> select bitmap_has_any(to_bitmap(1),to_bitmap(1)) cnt;
-+------+
-| cnt  |
-+------+
-|    1 |
-+------+
+mysql> select bitmap_has_any(to_bitmap(1),to_bitmap(2));
++--------------------------------------------+
+| bitmap_has_any(to_bitmap(1), to_bitmap(2)) |
++--------------------------------------------+
+|                                          0 |
++--------------------------------------------+
+
+mysql> select bitmap_has_any(to_bitmap(1),to_bitmap(1));
++--------------------------------------------+
+| bitmap_has_any(to_bitmap(1), to_bitmap(1)) |
++--------------------------------------------+
+|                                          1 |
++--------------------------------------------+
 ```
 
 ### keywords
diff --git a/docs/en/docs/sql-manual/sql-functions/bitmap-functions/bitmap_hash64.md b/docs/en/docs/sql-manual/sql-functions/bitmap-functions/bitmap_hash64.md
index e633df9b94..a9a9f03e6d 100644
--- a/docs/en/docs/sql-manual/sql-functions/bitmap-functions/bitmap_hash64.md
+++ b/docs/en/docs/sql-manual/sql-functions/bitmap-functions/bitmap_hash64.md
@@ -39,12 +39,12 @@ cat data | curl --location-trusted -u user:passwd -T - -H "columns: dt,page,devi
 ### example
 
 ```
-mysql> select bitmap_count(bitmap_hash64('hello'));
-+------------------------------------+
-| bitmap_count(bitmap_hash64('hello')) |
-+------------------------------------+
-|                                  1 |
-+------------------------------------+
+mysql> select bitmap_to_string(bitmap_hash64('hello'));
++------------------------------------------+
+| bitmap_to_string(bitmap_hash64('hello')) |
++------------------------------------------+
+| 15231136565543391023                     |
++------------------------------------------+
 ```
 
 ### keywords
diff --git a/docs/en/docs/sql-manual/sql-functions/bitmap-functions/bitmap_not.md b/docs/en/docs/sql-manual/sql-functions/bitmap-functions/bitmap_not.md
index 4d26248091..c3e5a069bd 100644
--- a/docs/en/docs/sql-manual/sql-functions/bitmap-functions/bitmap_not.md
+++ b/docs/en/docs/sql-manual/sql-functions/bitmap-functions/bitmap_not.md
@@ -35,16 +35,16 @@ Calculate the set after lhs minus rhs, return the new bitmap.
 ### example
 
 ```
-mysql> select bitmap_count(bitmap_not(bitmap_from_string('2,3'),bitmap_from_string('1,2,3,4'))) cnt;
-+------+
-| cnt  |
-+------+
-|    0 |
-+------+
+mysql> select bitmap_to_string(bitmap_not(bitmap_from_string('2,3'),bitmap_from_string('1,2,3,4')));
++----------------------------------------------------------------------------------------+
+| bitmap_to_string(bitmap_not(bitmap_from_string('2,3'), bitmap_from_string('1,2,3,4'))) |
++----------------------------------------------------------------------------------------+
+|                                                                                        |
++----------------------------------------------------------------------------------------+
 
 mysql> select bitmap_to_string(bitmap_not(bitmap_from_string('2,3,5'),bitmap_from_string('1,2,3,4')));
 +----------------------------------------------------------------------------------------+
-| bitmap_to_string(bitmap_xor(bitmap_from_string('2,3,5'), bitmap_from_string('1,2,3,4'))) |
+| bitmap_to_string(bitmap_not(bitmap_from_string('2,3,5'), bitmap_from_string('1,2,3,4'))) |
 +----------------------------------------------------------------------------------------+
 | 5                                                                                      |
 +----------------------------------------------------------------------------------------+
diff --git a/docs/en/docs/sql-manual/sql-functions/bitmap-functions/bitmap_or.md b/docs/en/docs/sql-manual/sql-functions/bitmap-functions/bitmap_or.md
index e5e9be9ac6..6754d8f321 100644
--- a/docs/en/docs/sql-manual/sql-functions/bitmap-functions/bitmap_or.md
+++ b/docs/en/docs/sql-manual/sql-functions/bitmap-functions/bitmap_or.md
@@ -35,42 +35,49 @@ Compute union of two or more input bitmaps, returns the new bitmap.
 ### example
 
 ```
-mysql> select bitmap_count(bitmap_or(to_bitmap(1), to_bitmap(2))) cnt;
+mysql> select bitmap_count(bitmap_or(to_bitmap(1), to_bitmap(1))) cnt;
 +------+
 | cnt  |
 +------+
-|    2 |
+|    1 |
 +------+
 
-mysql> select bitmap_count(bitmap_or(to_bitmap(1), to_bitmap(1))) cnt;
+mysql> select bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(1))) ;
++---------------------------------------------------------+
+| bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(1))) |
++---------------------------------------------------------+
+| 1                                                       |
++---------------------------------------------------------+
+
+mysql> select bitmap_count(bitmap_or(to_bitmap(1), to_bitmap(2))) cnt;
 +------+
 | cnt  |
 +------+
-|    1 |
+|    2 |
 +------+
 
-MySQL> select bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(2)));
+mysql> select bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(2)));
 +---------------------------------------------------------+
 | bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(2))) |
 +---------------------------------------------------------+
 | 1,2                                                     |
 +---------------------------------------------------------+
 
-MySQL> select bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(2), to_bitmap(10), to_bitmap(0), NULL));
+mysql> select bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(2), to_bitmap(10), to_bitmap(0), NULL));
 +--------------------------------------------------------------------------------------------+
 | bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(2), to_bitmap(10), to_bitmap(0), NULL)) |
 +--------------------------------------------------------------------------------------------+
-| NULL                                                                                       |
+| 0,1,2,10                                                                                   |
 +--------------------------------------------------------------------------------------------+
 
-MySQL> select bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(2),to_bitmap(10),to_bitmap(0),bitmap_empty()));
+mysql> select bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(2),to_bitmap(10),to_bitmap(0),bitmap_empty()));
 +------------------------------------------------------------------------------------------------------+
 | bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(2), to_bitmap(10), to_bitmap(0), bitmap_empty())) |
 +------------------------------------------------------------------------------------------------------+
 | 0,1,2,10                                                                                             |
 +------------------------------------------------------------------------------------------------------+
 
-MySQL> select bitmap_to_string(bitmap_or(to_bitmap(10), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))) ;
+mysql> select bitmap_to_string(bitmap_or(to_bitmap(10), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))) ;
 +--------------------------------------------------------------------------------------------------------+
 | bitmap_to_string(bitmap_or(to_bitmap(10), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))) |
 +--------------------------------------------------------------------------------------------------------+
diff --git a/docs/zh-CN/docs/sql-manual/sql-functions/bitmap-functions/bitmap_and.md b/docs/zh-CN/docs/sql-manual/sql-functions/bitmap-functions/bitmap_and.md
index 9e342842ed..ccb413ae81 100644
--- a/docs/zh-CN/docs/sql-manual/sql-functions/bitmap-functions/bitmap_and.md
+++ b/docs/zh-CN/docs/sql-manual/sql-functions/bitmap-functions/bitmap_and.md
@@ -42,6 +42,13 @@ mysql> select bitmap_count(bitmap_and(to_bitmap(1), to_bitmap(2))) cnt;
 |    0 |
 +------+
 
+mysql> select bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(2)));
++----------------------------------------------------------+
+| bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(2))) |
++----------------------------------------------------------+
+|                                                          |
++----------------------------------------------------------+
+
 mysql> select bitmap_count(bitmap_and(to_bitmap(1), to_bitmap(1))) cnt;
 +------+
 | cnt  |
@@ -49,28 +56,28 @@ mysql> select bitmap_count(bitmap_and(to_bitmap(1), to_bitmap(1))) cnt;
 |    1 |
 +------+
 
-MySQL> select bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(1)));
+mysql> select bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(1)));
 +----------------------------------------------------------+
 | bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(1))) |
 +----------------------------------------------------------+
 | 1                                                        |
 +----------------------------------------------------------+
 
-MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5')));
+mysql> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5')));
 +-----------------------------------------------------------------------------------------------------------------------+
 | bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))) |
 +-----------------------------------------------------------------------------------------------------------------------+
 | 1,2                                                                                                                   |
 +-----------------------------------------------------------------------------------------------------------------------+
 
-MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty()));
+mysql> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty()));
 +---------------------------------------------------------------------------------------------------------------------------------------+
 | bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), bitmap_empty())) |
 +---------------------------------------------------------------------------------------------------------------------------------------+
 |                                                                                                                                       |
 +---------------------------------------------------------------------------------------------------------------------------------------+
 
-MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),NULL));
+mysql> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),NULL));
 +-----------------------------------------------------------------------------------------------------------------------------+
 | bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL)) |
 +-----------------------------------------------------------------------------------------------------------------------------+
diff --git a/docs/zh-CN/docs/sql-manual/sql-functions/bitmap-functions/bitmap_and_not.md b/docs/zh-CN/docs/sql-manual/sql-functions/bitmap-functions/bitmap_and_not.md
index d24bcb3a87..f587af76c4 100644
--- a/docs/zh-CN/docs/sql-manual/sql-functions/bitmap-functions/bitmap_and_not.md
+++ b/docs/zh-CN/docs/sql-manual/sql-functions/bitmap-functions/bitmap_and_not.md
@@ -41,6 +41,27 @@ mysql> select bitmap_count(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_fro
 +------+
 |    2 |
 +------+
+
+mysql> select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5')));
++--------------------------------------------------------------------------------------------+
+| bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5'))) |
++--------------------------------------------------------------------------------------------+
+| 1,2                                                                                        |
++--------------------------------------------------------------------------------------------+
+
+mysql> select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_empty())) ;
++-------------------------------------------------------------------------------+
+| bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'), bitmap_empty())) |
++-------------------------------------------------------------------------------+
+| 1,2,3                                                                         |
++-------------------------------------------------------------------------------+
+
+mysql> select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),NULL));
++---------------------------------------------------------------------+
+| bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'), NULL)) |
++---------------------------------------------------------------------+
+| NULL                                                                |
++---------------------------------------------------------------------+
 ```
 
 ### keywords
diff --git a/docs/zh-CN/docs/sql-manual/sql-functions/bitmap-functions/bitmap_empty.md b/docs/zh-CN/docs/sql-manual/sql-functions/bitmap-functions/bitmap_empty.md
index b677f5ac11..f07e7343a2 100644
--- a/docs/zh-CN/docs/sql-manual/sql-functions/bitmap-functions/bitmap_empty.md
+++ b/docs/zh-CN/docs/sql-manual/sql-functions/bitmap-functions/bitmap_empty.md
@@ -45,6 +45,13 @@ mysql> select bitmap_count(bitmap_empty());
 +------------------------------+
 |                            0 |
 +------------------------------+
+
+mysql> select bitmap_to_string(bitmap_empty());
++----------------------------------+
+| bitmap_to_string(bitmap_empty()) |
++----------------------------------+
+|                                  |
++----------------------------------+
 ```
 
 ### keywords
diff --git a/docs/zh-CN/docs/sql-manual/sql-functions/bitmap-functions/bitmap_has_all.md b/docs/zh-CN/docs/sql-manual/sql-functions/bitmap-functions/bitmap_has_all.md
index c98f79313d..d38bfb4db5 100644
--- a/docs/zh-CN/docs/sql-manual/sql-functions/bitmap-functions/bitmap_has_all.md
+++ b/docs/zh-CN/docs/sql-manual/sql-functions/bitmap-functions/bitmap_has_all.md
@@ -36,19 +36,19 @@ under the License.
 ### example
 
 ```
-mysql> select bitmap_has_all(bitmap_from_string("0, 1, 2"), bitmap_from_string("1, 2")) cnt;
-+------+
-| cnt  |
-+------+
-|    1 |
-+------+
-
-mysql> select bitmap_has_all(bitmap_empty(), bitmap_from_string("1, 2")) cnt;
-+------+
-| cnt  |
-+------+
-|    0 |
-+------+
+mysql> select bitmap_has_all(bitmap_from_string("0, 1, 2"), bitmap_from_string("1, 2"));
++---------------------------------------------------------------------------+
+| bitmap_has_all(bitmap_from_string('0, 1, 2'), bitmap_from_string('1, 2')) |
++---------------------------------------------------------------------------+
+|                                                                         1 |
++---------------------------------------------------------------------------+
+
+mysql> select bitmap_has_all(bitmap_empty(), bitmap_from_string("1, 2"));
++------------------------------------------------------------+
+| bitmap_has_all(bitmap_empty(), bitmap_from_string('1, 2')) |
++------------------------------------------------------------+
+|                                                          0 |
++------------------------------------------------------------+
 ```
 
 ### keywords
diff --git a/docs/zh-CN/docs/sql-manual/sql-functions/bitmap-functions/bitmap_has_any.md b/docs/zh-CN/docs/sql-manual/sql-functions/bitmap-functions/bitmap_has_any.md
index 858228ae31..b483d885db 100644
--- a/docs/zh-CN/docs/sql-manual/sql-functions/bitmap-functions/bitmap_has_any.md
+++ b/docs/zh-CN/docs/sql-manual/sql-functions/bitmap-functions/bitmap_has_any.md
@@ -35,19 +35,19 @@ under the License.
 ### example
 
 ```
-mysql> select bitmap_has_any(to_bitmap(1),to_bitmap(2)) cnt;
-+------+
-| cnt  |
-+------+
-|    0 |
-+------+
-
-mysql> select bitmap_has_any(to_bitmap(1),to_bitmap(1)) cnt;
-+------+
-| cnt  |
-+------+
-|    1 |
-+------+
+mysql> select bitmap_has_any(to_bitmap(1),to_bitmap(2));
++--------------------------------------------+
+| bitmap_has_any(to_bitmap(1), to_bitmap(2)) |
++--------------------------------------------+
+|                                          0 |
++--------------------------------------------+
+
+mysql> select bitmap_has_any(to_bitmap(1),to_bitmap(1));
++--------------------------------------------+
+| bitmap_has_any(to_bitmap(1), to_bitmap(1)) |
++--------------------------------------------+
+|                                          1 |
++--------------------------------------------+
 ```
 
 ### keywords
diff --git a/docs/zh-CN/docs/sql-manual/sql-functions/bitmap-functions/bitmap_hash64.md b/docs/zh-CN/docs/sql-manual/sql-functions/bitmap-functions/bitmap_hash64.md
index 38c6bf22b7..a0c4f5d103 100644
--- a/docs/zh-CN/docs/sql-manual/sql-functions/bitmap-functions/bitmap_hash64.md
+++ b/docs/zh-CN/docs/sql-manual/sql-functions/bitmap-functions/bitmap_hash64.md
@@ -39,12 +39,12 @@ cat data | curl --location-trusted -u user:passwd -T - -H "columns: dt,page,devi
 ### example
 
 ```
-mysql> select bitmap_count(bitmap_hash64('hello'));
-+------------------------------------+
-| bitmap_count(bitmap_hash64('hello')) |
-+------------------------------------+
-|                                  1 |
-+------------------------------------+
+mysql> select bitmap_to_string(bitmap_hash64('hello'));
++------------------------------------------+
+| bitmap_to_string(bitmap_hash64('hello')) |
++------------------------------------------+
+| 15231136565543391023                     |
++------------------------------------------+
 ```
 
 ### keywords
diff --git a/docs/zh-CN/docs/sql-manual/sql-functions/bitmap-functions/bitmap_not.md b/docs/zh-CN/docs/sql-manual/sql-functions/bitmap-functions/bitmap_not.md
index d2e27f2a64..8c346939b8 100644
--- a/docs/zh-CN/docs/sql-manual/sql-functions/bitmap-functions/bitmap_not.md
+++ b/docs/zh-CN/docs/sql-manual/sql-functions/bitmap-functions/bitmap_not.md
@@ -35,19 +35,19 @@ under the License.
 ### example
 
 ```
-mysql> select bitmap_count(bitmap_not(bitmap_from_string('2,3'),bitmap_from_string('1,2,3,4'))) cnt;
-+------+
-| cnt  |
-+------+
-|    0 |
-+------+
-
-mysql> select bitmap_to_string(bitmap_not(bitmap_from_string('2,3,5'),bitmap_from_string('1,2,3,4')));
+mysql> select bitmap_to_string(bitmap_not(bitmap_from_string('2,3'),bitmap_from_string('1,2,3,4')));
 +----------------------------------------------------------------------------------------+
-| bitmap_to_string(bitmap_xor(bitmap_from_string('2,3,5'), bitmap_from_string('1,2,3,4'))) |
+| bitmap_to_string(bitmap_not(bitmap_from_string('2,3'), bitmap_from_string('1,2,3,4'))) |
 +----------------------------------------------------------------------------------------+
-| 5                                                                                      |
+|                                                                                        |
 +----------------------------------------------------------------------------------------+
+
+mysql> select bitmap_to_string(bitmap_not(bitmap_from_string('2,3,5'),bitmap_from_string('1,2,3,4')));
++------------------------------------------------------------------------------------------+
+| bitmap_to_string(bitmap_not(bitmap_from_string('2,3,5'), bitmap_from_string('1,2,3,4'))) |
++------------------------------------------------------------------------------------------+
+| 5                                                                                        |
++------------------------------------------------------------------------------------------+
 ```
 
 ### keywords
diff --git a/docs/zh-CN/docs/sql-manual/sql-functions/bitmap-functions/bitmap_or.md b/docs/zh-CN/docs/sql-manual/sql-functions/bitmap-functions/bitmap_or.md
index 90c5f89590..811777fa8a 100644
--- a/docs/zh-CN/docs/sql-manual/sql-functions/bitmap-functions/bitmap_or.md
+++ b/docs/zh-CN/docs/sql-manual/sql-functions/bitmap-functions/bitmap_or.md
@@ -35,42 +35,49 @@ under the License.
 ### example
 
 ```
-mysql> select bitmap_count(bitmap_or(to_bitmap(1), to_bitmap(2))) cnt;
+mysql> select bitmap_count(bitmap_or(to_bitmap(1), to_bitmap(1))) cnt;
 +------+
 | cnt  |
 +------+
-|    2 |
+|    1 |
 +------+
 
-mysql> select bitmap_count(bitmap_or(to_bitmap(1), to_bitmap(1))) cnt;
+mysql> select bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(1))) ;
++---------------------------------------------------------+
+| bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(1))) |
++---------------------------------------------------------+
+| 1                                                       |
++---------------------------------------------------------+
+
+mysql> select bitmap_count(bitmap_or(to_bitmap(1), to_bitmap(2))) cnt;
 +------+
 | cnt  |
 +------+
-|    1 |
+|    2 |
 +------+
 
-MySQL> select bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(2)));
+mysql> select bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(2)));
 +---------------------------------------------------------+
 | bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(2))) |
 +---------------------------------------------------------+
 | 1,2                                                     |
 +---------------------------------------------------------+
 
-MySQL> select bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(2), to_bitmap(10), to_bitmap(0), NULL));
+mysql> select bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(2), to_bitmap(10), to_bitmap(0), NULL));
 +--------------------------------------------------------------------------------------------+
 | bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(2), to_bitmap(10), to_bitmap(0), NULL)) |
 +--------------------------------------------------------------------------------------------+
-| NULL                                                                                       |
+| 0,1,2,10                                                                                   |
 +--------------------------------------------------------------------------------------------+
 
-MySQL> select bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(2), to_bitmap(10), to_bitmap(0), bitmap_empty()));
+mysql> select bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(2), to_bitmap(10), to_bitmap(0), bitmap_empty()));
 +------------------------------------------------------------------------------------------------------+
 | bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(2), to_bitmap(10), to_bitmap(0), bitmap_empty())) |
 +------------------------------------------------------------------------------------------------------+
 | 0,1,2,10                                                                                             |
 +------------------------------------------------------------------------------------------------------+
 
-MySQL> select bitmap_to_string(bitmap_or(to_bitmap(10), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5')));
+mysql> select bitmap_to_string(bitmap_or(to_bitmap(10), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5')));
 +--------------------------------------------------------------------------------------------------------+
 | bitmap_to_string(bitmap_or(to_bitmap(10), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))) |
 +--------------------------------------------------------------------------------------------------------+


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


[doris] 20/38: [fix](catalog) wrong required slot info causing BE crash. (#21702)

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 edeb981536f75bbb916c677f4e82442580fe8ee5
Author: Qi Chen <ka...@gmail.com>
AuthorDate: Wed Jul 12 09:33:17 2023 +0800

    [fix](catalog) wrong required slot info causing BE crash. (#21702)
    
    Merge #21598 to branch-1.2-lts.
    Co-Authored-By: morningman morningman@163.com
---
 .../apache/doris/datasource/hive/HiveMetaStoreCache.java  |  2 +-
 .../doris/planner/external/ExternalFileScanNode.java      |  1 +
 .../apache/doris/planner/external/HiveScanProvider.java   | 15 ++++++++++++++-
 .../hive/test_external_catalog_hive.out                   |  3 +++
 .../hive/test_external_catalog_hive.groovy                |  2 ++
 5 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HiveMetaStoreCache.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HiveMetaStoreCache.java
index 778fb10262..169ed3727b 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HiveMetaStoreCache.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HiveMetaStoreCache.java
@@ -701,7 +701,7 @@ public class HiveMetaStoreCache {
                 return dummyKey.equals(((FileCacheKey) obj).dummyKey);
             }
             return location.equals(((FileCacheKey) obj).location)
-                && partitionValues.equals(((FileCacheKey) obj).partitionValues);
+                && Objects.equals(partitionValues, ((FileCacheKey) obj).partitionValues);
         }
 
         @Override
diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/external/ExternalFileScanNode.java b/fe/fe-core/src/main/java/org/apache/doris/planner/external/ExternalFileScanNode.java
index 1aadb1e5c6..c94305233f 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/external/ExternalFileScanNode.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/external/ExternalFileScanNode.java
@@ -353,6 +353,7 @@ public class ExternalFileScanNode extends ExternalScanNode {
             if (scanProvider instanceof HiveScanProvider) {
                 this.totalPartitionNum = ((HiveScanProvider) scanProvider).getTotalPartitionNum();
                 this.readPartitionNum = ((HiveScanProvider) scanProvider).getReadPartitionNum();
+                ((HiveScanProvider) scanProvider).updateRequiredSlots(context);
             }
         }
     }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/external/HiveScanProvider.java b/fe/fe-core/src/main/java/org/apache/doris/planner/external/HiveScanProvider.java
index 845d62f92c..94d50ebd45 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/external/HiveScanProvider.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/external/HiveScanProvider.java
@@ -258,6 +258,19 @@ public class HiveScanProvider extends HMSTableScanProvider {
         List<String> partitionKeys = getPathPartitionKeys();
         List<Column> columns = hmsTable.getBaseSchema(false);
         context.params.setNumOfColumnsFromFile(columns.size() - partitionKeys.size());
+        updateRequiredSlots(context);
+        return context;
+    }
+
+    public void updateRequiredSlots(ParamCreateContext context) throws UserException {
+        updateRequiredSlots(context, null);
+    }
+
+    public void updateRequiredSlots(ParamCreateContext context, List<String> partitionKeys) throws UserException {
+        context.params.unsetRequiredSlots();
+        if (partitionKeys == null) {
+            partitionKeys = getPathPartitionKeys();
+        }
         for (SlotDescriptor slot : desc.getSlots()) {
             if (!slot.isMaterialized()) {
                 continue;
@@ -268,9 +281,9 @@ public class HiveScanProvider extends HMSTableScanProvider {
             slotInfo.setIsFileSlot(!partitionKeys.contains(slot.getColumn().getName()));
             context.params.addToRequiredSlots(slotInfo);
         }
-        return context;
     }
 
+
     @Override
     public TFileAttributes getFileAttributes() throws UserException {
         TFileTextScanRangeParams textParams = new TFileTextScanRangeParams();
diff --git a/regression-test/data/external_table_emr_p2/hive/test_external_catalog_hive.out b/regression-test/data/external_table_emr_p2/hive/test_external_catalog_hive.out
index b7a66d44d4..54dc2d9a40 100644
--- a/regression-test/data/external_table_emr_p2/hive/test_external_catalog_hive.out
+++ b/regression-test/data/external_table_emr_p2/hive/test_external_catalog_hive.out
@@ -93,3 +93,6 @@ moccasin steel bisque cornsilk lace
 -- !q25 --
 Z6n2t4XA2n7CXTECJ,PE,iBbsCh0RE1Dd2A,z48
 
+-- !pr21598 --
+5
+
diff --git a/regression-test/suites/external_table_emr_p2/hive/test_external_catalog_hive.groovy b/regression-test/suites/external_table_emr_p2/hive/test_external_catalog_hive.groovy
index 10bcea354e..ca445dbcda 100644
--- a/regression-test/suites/external_table_emr_p2/hive/test_external_catalog_hive.groovy
+++ b/regression-test/suites/external_table_emr_p2/hive/test_external_catalog_hive.groovy
@@ -87,6 +87,8 @@ suite("test_external_catalog_hive", "p2") {
         sql """ use tpch_1000_orc; """
         q03()
 
+        // test #21598
+        qt_pr21598 """select count(*) from( (SELECT r_regionkey AS key1, r_name AS name, pday AS pday FROM (SELECT r_regionkey, r_name, replace(r_comment, ' ', 'aaaa') AS pday FROM ${catalog_name}.tpch_1000_parquet.region) t2))x;"""
 
         // test remember last used database after switch / rename catalog
         sql """switch ${catalog_name};"""


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


[doris] 36/38: [tools][ckb] update q29 (#21842)

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 3b409ea5e432dbfc1773220c4e36884e2c5fa052
Author: Dongyang Li <he...@qq.com>
AuthorDate: Wed Jul 19 01:32:40 2023 +0800

    [tools][ckb] update q29 (#21842)
---
 tools/clickbench-tools/sql/queries.sql | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/clickbench-tools/sql/queries.sql b/tools/clickbench-tools/sql/queries.sql
index 2f54a52229..0d29f4d413 100644
--- a/tools/clickbench-tools/sql/queries.sql
+++ b/tools/clickbench-tools/sql/queries.sql
@@ -43,7 +43,7 @@ SELECT SearchPhrase FROM hits WHERE SearchPhrase <> '' ORDER BY EventTime LIMIT
 SELECT SearchPhrase FROM hits WHERE SearchPhrase <> '' ORDER BY SearchPhrase LIMIT 10;
 SELECT SearchPhrase FROM hits WHERE SearchPhrase <> '' ORDER BY EventTime, SearchPhrase LIMIT 10;
 SELECT CounterID, AVG(length(URL)) AS l, COUNT(*) AS c FROM hits WHERE URL <> '' GROUP BY CounterID HAVING COUNT(*) > 100000 ORDER BY l DESC LIMIT 25;
-SELECT REGEXP_REPLACE(Referer, '^https?://(?:www\.)?([^/]+)/.*$', '\1') AS k, AVG(length(Referer)) AS l, COUNT(*) AS c, MIN(Referer) FROM hits WHERE Referer <> '' GROUP BY k HAVING COUNT(*) > 100000 ORDER BY l DESC LIMIT 25;
+SELECT REGEXP_REPLACE(Referer, '^https?://(?:www\.)?([^/]+)/.*$', '\\1') AS k, AVG(length(Referer)) AS l, COUNT(*) AS c, MIN(Referer) FROM hits WHERE Referer <> '' GROUP BY k HAVING COUNT(*) > 100000 ORDER BY l DESC LIMIT 25;
 SELECT SUM(ResolutionWidth), SUM(ResolutionWidth + 1), SUM(ResolutionWidth + 2), SUM(ResolutionWidth + 3), SUM(ResolutionWidth + 4), SUM(ResolutionWidth + 5), SUM(ResolutionWidth + 6), SUM(ResolutionWidth + 7), SUM(ResolutionWidth + 8), SUM(ResolutionWidth + 9), SUM(ResolutionWidth + 10), SUM(ResolutionWidth + 11), SUM(ResolutionWidth + 12), SUM(ResolutionWidth + 13), SUM(ResolutionWidth + 14), SUM(ResolutionWidth + 15), SUM(ResolutionWidth + 16), SUM(ResolutionWidth + 17), SUM(Resolutio [...]
 SELECT SearchEngineID, ClientIP, COUNT(*) AS c, SUM(IsRefresh), AVG(ResolutionWidth) FROM hits WHERE SearchPhrase <> '' GROUP BY SearchEngineID, ClientIP ORDER BY c DESC LIMIT 10;
 SELECT WatchID, ClientIP, COUNT(*) AS c, SUM(IsRefresh), AVG(ResolutionWidth) FROM hits WHERE SearchPhrase <> '' GROUP BY WatchID, ClientIP ORDER BY c DESC LIMIT 10;


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


[doris] 18/38: [improvement](bitmap) Use shared_ptr in BitmapValue to avoid deep copying (#19101) (#21271)

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 23b964492d2e6d23b34231c07d4bda22a8625333
Author: Jerry Hu <mr...@gmail.com>
AuthorDate: Tue Jul 11 18:34:20 2023 +0800

    [improvement](bitmap) Use shared_ptr in BitmapValue to avoid deep copying (#19101) (#21271)
    
    Currently bitmapvalue type is copied between columns, it cost a lot of memory. Use a shared ptr in bitmap value to avoid copy data.
---
 be/src/util/bitmap_value.h         | 227 +++++++++++++++++++++++++------------
 be/test/util/bitmap_value_test.cpp |  22 ++++
 2 files changed, 178 insertions(+), 71 deletions(-)

diff --git a/be/src/util/bitmap_value.h b/be/src/util/bitmap_value.h
index 21fa5f217e..f2c869f862 100644
--- a/be/src/util/bitmap_value.h
+++ b/be/src/util/bitmap_value.h
@@ -1144,10 +1144,10 @@ class BitmapValueIterator;
 class BitmapValue {
 public:
     // Construct an empty bitmap.
-    BitmapValue() : _type(EMPTY) {}
+    BitmapValue() : _type(EMPTY), _is_shared(false) {}
 
     // Construct a bitmap with one element.
-    explicit BitmapValue(uint64_t value) : _sv(value), _type(SINGLE) {}
+    explicit BitmapValue(uint64_t value) : _sv(value), _type(SINGLE), _is_shared(false) {}
 
     // Construct a bitmap from serialized data.
     explicit BitmapValue(const char* src) {
@@ -1155,8 +1155,48 @@ public:
         DCHECK(res);
     }
 
+    BitmapValue(const BitmapValue& other) {
+        _type = other._type;
+        _sv = other._sv;
+        _bitmap = other._bitmap;
+        _is_shared = true;
+        // should also set other's state to shared, so that other bitmap value will
+        // create a new bitmap when it wants to modify it.
+        const_cast<BitmapValue&>(other)._is_shared = true;
+    }
+
+    BitmapValue(BitmapValue&& other) {
+        _type = other._type;
+        _sv = other._sv;
+        _is_shared = other._is_shared;
+        _bitmap = std::move(other._bitmap);
+    }
+
+    BitmapValue& operator=(const BitmapValue& other) {
+        _type = other._type;
+        _sv = other._sv;
+        _bitmap = other._bitmap;
+        _is_shared = true;
+        // should also set other's state to shared, so that other bitmap value will
+        // create a new bitmap when it wants to modify it.
+        const_cast<BitmapValue&>(other)._is_shared = true;
+        return *this;
+    }
+
+    BitmapValue& operator=(BitmapValue&& other) {
+        if (this == &other) {
+            return *this;
+        }
+
+        _type = other._type;
+        _sv = other._sv;
+        _bitmap = std::move(other._bitmap);
+        _is_shared = other._is_shared;
+        return *this;
+    }
+
     // Construct a bitmap from given elements.
-    explicit BitmapValue(const std::vector<uint64_t>& bits) {
+    explicit BitmapValue(const std::vector<uint64_t>& bits) : _is_shared(false) {
         switch (bits.size()) {
         case 0:
             _type = EMPTY;
@@ -1167,7 +1207,8 @@ public:
             break;
         default:
             _type = BITMAP;
-            _bitmap.addMany(bits.size(), &bits[0]);
+            _prepare_bitmap_for_write();
+            _bitmap->addMany(bits.size(), &bits[0]);
         }
     }
 
@@ -1182,12 +1223,15 @@ public:
             if (_sv == value) {
                 break;
             }
-            _bitmap.add(_sv);
-            _bitmap.add(value);
+            _prepare_bitmap_for_write();
+            _bitmap->add(_sv);
+            _bitmap->add(value);
             _type = BITMAP;
             break;
         case BITMAP:
-            _bitmap.add(value);
+            _prepare_bitmap_for_write();
+            _bitmap->add(value);
+            break;
         }
     }
 
@@ -1202,7 +1246,8 @@ public:
             }
             break;
         case BITMAP:
-            _bitmap.remove(value);
+            _prepare_bitmap_for_write();
+            _bitmap->remove(value);
             _convert_to_smaller_type();
         }
     }
@@ -1220,12 +1265,13 @@ public:
             case EMPTY:
                 break;
             case SINGLE:
-                if (rhs._bitmap.contains(_sv)) {
+                if (rhs._bitmap->contains(_sv)) {
                     _type = EMPTY;
                 }
                 break;
             case BITMAP:
-                _bitmap -= rhs._bitmap;
+                _prepare_bitmap_for_write();
+                *_bitmap -= *rhs._bitmap;
                 _convert_to_smaller_type();
                 break;
             }
@@ -1250,15 +1296,21 @@ public:
             switch (_type) {
             case EMPTY:
                 _bitmap = rhs._bitmap;
+                const_cast<BitmapValue&>(rhs)._is_shared = true;
+                _is_shared = true;
                 _type = BITMAP;
                 break;
             case SINGLE:
                 _bitmap = rhs._bitmap;
-                _bitmap.add(_sv);
+                const_cast<BitmapValue&>(rhs)._is_shared = true;
+                _is_shared = true;
+                _prepare_bitmap_for_write();
+                _bitmap->add(_sv);
                 _type = BITMAP;
                 break;
             case BITMAP:
-                _bitmap |= rhs._bitmap;
+                _prepare_bitmap_for_write();
+                *_bitmap |= *rhs._bitmap;
             }
             break;
         }
@@ -1277,24 +1329,25 @@ public:
                 single_values.push_back(value->_sv);
                 break;
             case BITMAP:
-                bitmaps.push_back(&value->_bitmap);
+                bitmaps.push_back(value->_bitmap.get());
                 break;
             }
         }
 
         if (!bitmaps.empty()) {
+            _prepare_bitmap_for_write();
             switch (_type) {
             case EMPTY:
-                _bitmap = detail::Roaring64Map::fastunion(bitmaps.size(), bitmaps.data());
+                *_bitmap = detail::Roaring64Map::fastunion(bitmaps.size(), bitmaps.data());
                 _type = BITMAP;
                 break;
             case SINGLE:
-                _bitmap = detail::Roaring64Map::fastunion(bitmaps.size(), bitmaps.data());
-                _bitmap.add(_sv);
+                *_bitmap = detail::Roaring64Map::fastunion(bitmaps.size(), bitmaps.data());
+                _bitmap->add(_sv);
                 _type = BITMAP;
                 break;
             case BITMAP:
-                _bitmap |= detail::Roaring64Map::fastunion(bitmaps.size(), bitmaps.data());
+                *_bitmap |= detail::Roaring64Map::fastunion(bitmaps.size(), bitmaps.data());
                 break;
             }
         }
@@ -1303,9 +1356,10 @@ public:
             _sv = single_values[0];
             _type = SINGLE;
         } else if (!single_values.empty()) {
-            _bitmap.addMany(single_values.size(), single_values.data());
+            _prepare_bitmap_for_write();
+            _bitmap->addMany(single_values.size(), single_values.data());
             if (_type == SINGLE) {
-                _bitmap.add(_sv);
+                _bitmap->add(_sv);
             }
             _type = BITMAP;
         }
@@ -1322,7 +1376,7 @@ public:
         switch (rhs._type) {
         case EMPTY:
             _type = EMPTY;
-            _bitmap.clear();
+            _bitmap.reset();
             break;
         case SINGLE:
             switch (_type) {
@@ -1334,13 +1388,13 @@ public:
                 }
                 break;
             case BITMAP:
-                if (!_bitmap.contains(rhs._sv)) {
+                if (!_bitmap->contains(rhs._sv)) {
                     _type = EMPTY;
                 } else {
                     _type = SINGLE;
                     _sv = rhs._sv;
                 }
-                _bitmap.clear();
+                _bitmap.reset();
                 break;
             }
             break;
@@ -1349,12 +1403,13 @@ public:
             case EMPTY:
                 break;
             case SINGLE:
-                if (!rhs._bitmap.contains(_sv)) {
+                if (!rhs._bitmap->contains(_sv)) {
                     _type = EMPTY;
                 }
                 break;
             case BITMAP:
-                _bitmap &= rhs._bitmap;
+                _prepare_bitmap_for_write();
+                *_bitmap &= *rhs._bitmap;
                 _convert_to_smaller_type();
                 break;
             }
@@ -1380,16 +1435,17 @@ public:
             case SINGLE:
                 if (_sv == rhs._sv) {
                     _type = EMPTY;
-                    _bitmap.clear();
+                    _bitmap.reset();
                 } else {
                     add(rhs._sv);
                 }
                 break;
             case BITMAP:
-                if (!_bitmap.contains(rhs._sv)) {
+                if (!_bitmap->contains(rhs._sv)) {
                     add(rhs._sv);
                 } else {
-                    _bitmap.remove(rhs._sv);
+                    _prepare_bitmap_for_write();
+                    _bitmap->remove(rhs._sv);
                 }
                 break;
             }
@@ -1398,19 +1454,25 @@ public:
             switch (_type) {
             case EMPTY:
                 _bitmap = rhs._bitmap;
+                const_cast<BitmapValue&>(rhs)._is_shared = true;
+                _is_shared = true;
                 _type = BITMAP;
                 break;
             case SINGLE:
                 _bitmap = rhs._bitmap;
+                const_cast<BitmapValue&>(rhs)._is_shared = true;
+                _is_shared = true;
                 _type = BITMAP;
-                if (!rhs._bitmap.contains(_sv)) {
-                    _bitmap.add(_sv);
+                _prepare_bitmap_for_write();
+                if (!rhs._bitmap->contains(_sv)) {
+                    _bitmap->add(_sv);
                 } else {
-                    _bitmap.remove(_sv);
+                    _bitmap->remove(_sv);
                 }
                 break;
             case BITMAP:
-                _bitmap ^= rhs._bitmap;
+                _prepare_bitmap_for_write();
+                *_bitmap ^= *rhs._bitmap;
                 _convert_to_smaller_type();
                 break;
             }
@@ -1427,7 +1489,7 @@ public:
         case SINGLE:
             return _sv == x;
         case BITMAP:
-            return _bitmap.contains(x);
+            return _bitmap->contains(x);
         }
         return false;
     }
@@ -1442,7 +1504,7 @@ public:
         case SINGLE:
             return 1;
         case BITMAP:
-            return _bitmap.cardinality();
+            return _bitmap->cardinality();
         }
         return 0;
     }
@@ -1458,16 +1520,16 @@ public:
             case SINGLE:
                 return _sv == rhs._sv;
             case BITMAP:
-                return _bitmap.contains(rhs._sv);
+                return _bitmap->contains(rhs._sv);
             }
         case BITMAP:
             switch (_type) {
             case EMPTY:
                 return 0;
             case SINGLE:
-                return rhs._bitmap.contains(_sv);
+                return rhs._bitmap->contains(_sv);
             case BITMAP:
-                return _bitmap.andCardinality(rhs._bitmap);
+                return _bitmap->andCardinality(*rhs._bitmap);
             }
         }
         return 0;
@@ -1484,16 +1546,16 @@ public:
             case SINGLE:
                 return 1 + (_sv != rhs._sv);
             case BITMAP:
-                return cardinality() + !_bitmap.contains(rhs._sv);
+                return cardinality() + !_bitmap->contains(rhs._sv);
             }
         case BITMAP:
             switch (_type) {
             case EMPTY:
                 return rhs.cardinality();
             case SINGLE:
-                return rhs.cardinality() + !rhs._bitmap.contains(_sv);
+                return rhs.cardinality() + !rhs._bitmap->contains(_sv);
             case BITMAP:
-                return _bitmap.orCardinality(rhs._bitmap);
+                return _bitmap->orCardinality(*rhs._bitmap);
             }
         }
         return 0;
@@ -1510,16 +1572,16 @@ public:
             case SINGLE:
                 return 2 - 2 * (_sv == rhs._sv);
             case BITMAP:
-                return cardinality() + 1 - 2 * (_bitmap.contains(rhs._sv));
+                return cardinality() + 1 - 2 * (_bitmap->contains(rhs._sv));
             }
         case BITMAP:
             switch (_type) {
             case EMPTY:
                 return rhs.cardinality();
             case SINGLE:
-                return rhs.cardinality() + 1 - 2 * (rhs._bitmap.contains(_sv));
+                return rhs.cardinality() + 1 - 2 * (rhs._bitmap->contains(_sv));
             case BITMAP:
-                return _bitmap.xorCardinality(rhs._bitmap);
+                return _bitmap->xorCardinality(*rhs._bitmap);
             }
         }
         return 0;
@@ -1536,16 +1598,16 @@ public:
             case SINGLE:
                 return 1 - _sv == rhs._sv;
             case BITMAP:
-                return cardinality() - _bitmap.contains(rhs._sv);
+                return cardinality() - _bitmap->contains(rhs._sv);
             }
         case BITMAP:
             switch (_type) {
             case EMPTY:
                 return 0;
             case SINGLE:
-                return !rhs._bitmap.contains(_sv);
+                return !rhs._bitmap->contains(_sv);
             case BITMAP:
-                return _bitmap.andnotCardinality(rhs._bitmap);
+                return _bitmap->andnotCardinality(*rhs._bitmap);
             }
         }
         return 0;
@@ -1567,9 +1629,9 @@ public:
             }
             break;
         case BITMAP:
-            _bitmap.runOptimize();
-            _bitmap.shrinkToFit();
-            res = _bitmap.getSizeInBytes();
+            _bitmap->runOptimize();
+            _bitmap->shrinkToFit();
+            res = _bitmap->getSizeInBytes();
             break;
         }
         return res;
@@ -1592,7 +1654,7 @@ public:
             }
             break;
         case BITMAP:
-            _bitmap.write(dst);
+            _bitmap->write(dst);
             break;
         }
     }
@@ -1615,7 +1677,8 @@ public:
         case BitmapTypeCode::BITMAP32:
         case BitmapTypeCode::BITMAP64:
             _type = BITMAP;
-            _bitmap = detail::Roaring64Map::read(src);
+            _prepare_bitmap_for_write();
+            *_bitmap = detail::Roaring64Map::read(src);
             break;
         default:
             LOG(ERROR) << "BitmapTypeCode invalid, should between: " << BitmapTypeCode::EMPTY
@@ -1631,7 +1694,7 @@ public:
         case SINGLE:
             return doris_udf::BigIntVal(_sv);
         case BITMAP:
-            return doris_udf::BigIntVal(_bitmap.minimum());
+            return doris_udf::BigIntVal(_bitmap->minimum());
         default:
             return doris_udf::BigIntVal::null();
         }
@@ -1653,7 +1716,7 @@ public:
             } iter_ctx;
             iter_ctx.ss = &ss;
 
-            _bitmap.iterate(
+            _bitmap->iterate(
                     [](uint64_t value, void* c) -> bool {
                         auto ctx = reinterpret_cast<IterCtx*>(c);
                         if (ctx->first) {
@@ -1676,18 +1739,18 @@ public:
         case SINGLE:
             return doris_udf::BigIntVal(_sv);
         case BITMAP:
-            return doris_udf::BigIntVal(_bitmap.maximum());
+            return doris_udf::BigIntVal(_bitmap->maximum());
         default:
             return doris_udf::BigIntVal::null();
         }
     }
 
     uint64_t max(bool* empty) const {
-        return min_or_max(empty, [&]() { return _bitmap.maximum(); });
+        return min_or_max(empty, [&]() { return _bitmap->maximum(); });
     }
 
     uint64_t min(bool* empty) const {
-        return min_or_max(empty, [&]() { return _bitmap.minimum(); });
+        return min_or_max(empty, [&]() { return _bitmap->minimum(); });
     }
 
     bool empty() const { return _type == EMPTY; }
@@ -1711,7 +1774,7 @@ public:
         }
         case BITMAP: {
             int64_t count = 0;
-            for (auto it = _bitmap.begin(); it != _bitmap.end(); ++it) {
+            for (auto it = _bitmap->begin(); it != _bitmap->end(); ++it) {
                 if (*it < range_start) {
                     continue;
                 }
@@ -1750,7 +1813,7 @@ public:
         }
         case BITMAP: {
             int64_t count = 0;
-            for (auto it = _bitmap.begin(); it != _bitmap.end(); ++it) {
+            for (auto it = _bitmap->begin(); it != _bitmap->end(); ++it) {
                 if (*it < range_start) {
                     continue;
                 }
@@ -1786,23 +1849,23 @@ public:
             }
         }
         case BITMAP: {
-            if (std::abs(offset) >= _bitmap.cardinality()) {
+            if (std::abs(offset) >= _bitmap->cardinality()) {
                 return 0;
             }
         }
         }
         int64_t abs_offset = offset;
         if (offset < 0) {
-            abs_offset = _bitmap.cardinality() + offset;
+            abs_offset = _bitmap->cardinality() + offset;
         }
 
         int64_t count = 0;
         int64_t offset_count = 0;
-        auto it = _bitmap.begin();
-        for (; it != _bitmap.end() && offset_count < abs_offset; ++it) {
+        auto it = _bitmap->begin();
+        for (; it != _bitmap->end() && offset_count < abs_offset; ++it) {
             ++offset_count;
         }
-        for (; it != _bitmap.end() && count < limit; ++it, ++count) {
+        for (; it != _bitmap->end() && count < limit; ++it, ++count) {
             ret_bitmap->add(*it);
         }
         return count;
@@ -1818,7 +1881,7 @@ public:
             break;
         }
         case BITMAP: {
-            for (auto it = _bitmap.begin(); it != _bitmap.end(); ++it) {
+            for (auto it = _bitmap->begin(); it != _bitmap->end(); ++it) {
                 data.emplace_back(*it);
             }
             break;
@@ -1828,7 +1891,7 @@ public:
 
     void clear() {
         _type = EMPTY;
-        _bitmap.clear();
+        _bitmap.reset();
         _sv = 0;
     }
 
@@ -1843,15 +1906,15 @@ public:
 private:
     void _convert_to_smaller_type() {
         if (_type == BITMAP) {
-            uint64_t c = _bitmap.cardinality();
+            uint64_t c = _bitmap->cardinality();
             if (c > 1) return;
             if (c == 0) {
                 _type = EMPTY;
             } else {
                 _type = SINGLE;
-                _sv = _bitmap.minimum();
+                _sv = _bitmap->minimum();
             }
-            _bitmap.clear();
+            _bitmap.reset();
         }
     }
 
@@ -1874,14 +1937,36 @@ private:
         return result;
     }
 
+    void _prepare_bitmap_for_write() {
+        if (!_bitmap) {
+            _bitmap = std::make_shared<detail::Roaring64Map>();
+            _is_shared = false;
+            return;
+        }
+
+        if (!_is_shared) {
+            // the state is not shared, not need to check use count any more
+            return;
+        }
+
+        if (_bitmap.use_count() > 1) {
+            auto new_one = std::make_shared<detail::Roaring64Map>();
+            *new_one = *_bitmap;
+            _bitmap = new_one;
+        }
+        _is_shared = false;
+    }
+
     enum BitmapDataType {
         EMPTY = 0,
         SINGLE = 1, // single element
         BITMAP = 2  // more than one elements
     };
-    uint64_t _sv = 0;             // store the single value when _type == SINGLE
-    detail::Roaring64Map _bitmap; // used when _type == BITMAP
-    BitmapDataType _type;
+    uint64_t _sv = 0;                              // store the single value when _type == SINGLE
+    std::shared_ptr<detail::Roaring64Map> _bitmap; // used when _type == BITMAP
+    BitmapDataType _type {EMPTY};
+    // Indicate whether the state is shared among multi BitmapValue object
+    bool _is_shared = true;
 };
 
 // A simple implement of bitmap value iterator(Read only)
@@ -1903,7 +1988,7 @@ public:
             _sv = _bitmap._sv;
             break;
         case BitmapValue::BitmapDataType::BITMAP:
-            _iter = new detail::Roaring64MapSetBitForwardIterator(_bitmap._bitmap, _end);
+            _iter = new detail::Roaring64MapSetBitForwardIterator(*_bitmap._bitmap, _end);
             break;
         default:
             CHECK(false) << _bitmap._type;
diff --git a/be/test/util/bitmap_value_test.cpp b/be/test/util/bitmap_value_test.cpp
index ee950744db..5964927d4d 100644
--- a/be/test/util/bitmap_value_test.cpp
+++ b/be/test/util/bitmap_value_test.cpp
@@ -27,6 +27,28 @@
 namespace doris {
 using roaring::Roaring;
 
+TEST(BitmapValueTest, copy) {
+    BitmapValue empty;
+    BitmapValue single(1024);
+    BitmapValue bitmap({1024, 1025, 1026});
+
+    BitmapValue copied = bitmap;
+    EXPECT_TRUE(copied.contains(1024));
+    EXPECT_TRUE(copied.contains(1025));
+    EXPECT_TRUE(copied.contains(1026));
+    copied &= single;
+
+    // value of copied changed.
+    EXPECT_TRUE(copied.contains(1024));
+    EXPECT_FALSE(copied.contains(1025));
+    EXPECT_FALSE(copied.contains(1026));
+
+    // value of bitmap not changed.
+    EXPECT_TRUE(bitmap.contains(1024));
+    EXPECT_TRUE(bitmap.contains(1025));
+    EXPECT_TRUE(bitmap.contains(1026));
+}
+
 TEST(BitmapValueTest, bitmap_union) {
     BitmapValue empty;
     BitmapValue single(1024);


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


[doris] 21/38: [Improve](array)improve array hash function (#21779)

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 bb91922f9bf5df006aa14c8c75492ce8d17638bb
Author: amory <wa...@selectdb.com>
AuthorDate: Thu Jul 13 11:53:54 2023 +0800

    [Improve](array)improve array hash function (#21779)
    
    cherry-pick from #21699
---
 be/src/util/timezone_utils.cpp         |  2 +
 be/src/vec/columns/column.h            |  8 +++-
 be/src/vec/columns/column_array.cpp    | 73 ++++++++++++++++++++++++++--------
 be/src/vec/columns/column_array.h      |  6 ++-
 be/src/vec/columns/column_const.h      |  8 ++--
 be/src/vec/columns/column_decimal.cpp  | 50 +++++++++++++++++------
 be/src/vec/columns/column_decimal.h    | 14 ++++++-
 be/src/vec/columns/column_nullable.cpp | 34 +++++++++++-----
 be/src/vec/columns/column_nullable.h   |  6 ++-
 be/src/vec/columns/column_string.h     | 42 +++++++++++++++----
 be/src/vec/columns/column_vector.h     | 42 +++++++++++++++----
 11 files changed, 219 insertions(+), 66 deletions(-)

diff --git a/be/src/util/timezone_utils.cpp b/be/src/util/timezone_utils.cpp
index c22c12b560..b746634e03 100644
--- a/be/src/util/timezone_utils.cpp
+++ b/be/src/util/timezone_utils.cpp
@@ -17,7 +17,9 @@
 //
 
 #include "util/timezone_utils.h"
+
 #include <cctz/time_zone.h>
+
 #include <boost/algorithm/string.hpp>
 #include <filesystem>
 #include <string>
diff --git a/be/src/vec/columns/column.h b/be/src/vec/columns/column.h
index 89dd4fbef4..c82944b44d 100644
--- a/be/src/vec/columns/column.h
+++ b/be/src/vec/columns/column.h
@@ -360,7 +360,9 @@ public:
         LOG(FATAL) << get_name() << "update_hashes_with_value xxhash not supported";
     };
 
-    virtual void update_xxHash_with_value(size_t n, uint64_t& hash) const {
+    // use range for one hash value to avoid virtual function call in loop
+    virtual void update_xxHash_with_value(size_t start, size_t end, uint64_t& hash,
+                                          const uint8_t* __restrict null_data) const {
         LOG(FATAL) << get_name() << " update_hash_with_value xxhash not supported";
     }
 
@@ -372,7 +374,9 @@ public:
         LOG(FATAL) << get_name() << "update_crcs_with_value not supported";
     };
 
-    virtual void update_crc_with_value(size_t n, uint64_t& hash) const {
+    // use range for one hash value to avoid virtual function call in loop
+    virtual void update_crc_with_value(size_t start, size_t end, uint64_t& hash,
+                                       const uint8_t* __restrict null_data) const {
         LOG(FATAL) << get_name() << " update_crc_with_value not supported";
     }
 
diff --git a/be/src/vec/columns/column_array.cpp b/be/src/vec/columns/column_array.cpp
index 999991fde5..6a2f40792b 100644
--- a/be/src/vec/columns/column_array.cpp
+++ b/be/src/vec/columns/column_array.cpp
@@ -229,25 +229,64 @@ void ColumnArray::update_hashes_with_value(std::vector<SipHash>& hashes,
 }
 
 // for every array row calculate xxHash
-void ColumnArray::update_xxHash_with_value(size_t n, uint64_t& hash) const {
-    size_t elem_size = size_at(n);
-    size_t offset = offset_at(n);
-    hash = HashUtil::xxHash64WithSeed(reinterpret_cast<const char*>(&elem_size), sizeof(elem_size),
-                                      hash);
-    for (auto i = 0; i < elem_size; ++i) {
-        get_data().update_xxHash_with_value(offset + i, hash);
+void ColumnArray::update_xxHash_with_value(size_t start, size_t end, uint64_t& hash,
+                                           const uint8_t* __restrict null_data) const {
+    auto& offsets_column = get_offsets();
+    if (null_data) {
+        for (size_t i = start; i < end; ++i) {
+            if (null_data[i] == 0) {
+                size_t elem_size = offsets_column[i] - offsets_column[i - 1];
+                if (elem_size == 0) {
+                    hash = HashUtil::xxHash64WithSeed(reinterpret_cast<const char*>(&elem_size),
+                                                      sizeof(elem_size), hash);
+                } else {
+                    get_data().update_crc_with_value(offsets_column[i - 1], offsets_column[i], hash,
+                                                     nullptr);
+                }
+            }
+        }
+    } else {
+        for (size_t i = start; i < end; ++i) {
+            size_t elem_size = offsets_column[i] - offsets_column[i - 1];
+            if (elem_size == 0) {
+                hash = HashUtil::xxHash64WithSeed(reinterpret_cast<const char*>(&elem_size),
+                                                  sizeof(elem_size), hash);
+            } else {
+                get_data().update_crc_with_value(offsets_column[i - 1], offsets_column[i], hash,
+                                                 nullptr);
+            }
+        }
     }
 }
 
 // for every array row calculate crcHash
-void ColumnArray::update_crc_with_value(size_t n, uint64_t& crc) const {
-    size_t elem_size = size_at(n);
-    size_t offset = offset_at(n);
-
-    crc = HashUtil::zlib_crc_hash(reinterpret_cast<const char*>(&elem_size), sizeof(elem_size),
-                                  crc);
-    for (auto i = 0; i < elem_size; ++i) {
-        get_data().update_crc_with_value(offset + i, crc);
+void ColumnArray::update_crc_with_value(size_t start, size_t end, uint64_t& hash,
+                                        const uint8_t* __restrict null_data) const {
+    auto& offsets_column = get_offsets();
+    if (null_data) {
+        for (size_t i = start; i < end; ++i) {
+            if (null_data[i] == 0) {
+                size_t elem_size = offsets_column[i] - offsets_column[i - 1];
+                if (elem_size == 0) {
+                    hash = HashUtil::zlib_crc_hash(reinterpret_cast<const char*>(&elem_size),
+                                                   sizeof(elem_size), hash);
+                } else {
+                    get_data().update_crc_with_value(offsets_column[i - 1], offsets_column[i], hash,
+                                                     nullptr);
+                }
+            }
+        }
+    } else {
+        for (size_t i = start; i < end; ++i) {
+            size_t elem_size = offsets_column[i] - offsets_column[i - 1];
+            if (elem_size == 0) {
+                hash = HashUtil::zlib_crc_hash(reinterpret_cast<const char*>(&elem_size),
+                                               sizeof(elem_size), hash);
+            } else {
+                get_data().update_crc_with_value(offsets_column[i - 1], offsets_column[i], hash,
+                                                 nullptr);
+            }
+        }
     }
 }
 
@@ -257,12 +296,12 @@ void ColumnArray::update_hashes_with_value(uint64_t* __restrict hashes,
     if (null_data) {
         for (size_t i = 0; i < s; ++i) {
             if (null_data[i] == 0) {
-                update_xxHash_with_value(i, hashes[i]);
+                update_xxHash_with_value(i, i + 1, hashes[i], nullptr);
             }
         }
     } else {
         for (size_t i = 0; i < s; ++i) {
-            update_xxHash_with_value(i, hashes[i]);
+            update_xxHash_with_value(i, i + 1, hashes[i], nullptr);
         }
     }
 }
diff --git a/be/src/vec/columns/column_array.h b/be/src/vec/columns/column_array.h
index 7239de3347..2725814fad 100644
--- a/be/src/vec/columns/column_array.h
+++ b/be/src/vec/columns/column_array.h
@@ -97,8 +97,10 @@ public:
     void insert_data(const char* pos, size_t length) override;
     StringRef serialize_value_into_arena(size_t n, Arena& arena, char const*& begin) const override;
     const char* deserialize_and_insert_from_arena(const char* pos) override;
-    void update_xxHash_with_value(size_t n, uint64_t& hash) const override;
-    void update_crc_with_value(size_t n, uint64_t& crc) const override;
+    void update_xxHash_with_value(size_t start, size_t end, uint64_t& hash,
+                                  const uint8_t* __restrict null_data) const override;
+    void update_crc_with_value(size_t start, size_t end, uint64_t& hash,
+                               const uint8_t* __restrict null_data) const override;
 
     void update_hashes_with_value(std::vector<SipHash>& hashes,
                                   const uint8_t* __restrict null_data) const override;
diff --git a/be/src/vec/columns/column_const.h b/be/src/vec/columns/column_const.h
index 13640a0a9a..05ffe9ac6f 100644
--- a/be/src/vec/columns/column_const.h
+++ b/be/src/vec/columns/column_const.h
@@ -135,7 +135,8 @@ public:
 
     void update_hashes_with_value(uint64_t* __restrict hashes,
                                   const uint8_t* __restrict null_data) const override;
-    void update_xxHash_with_value(size_t n, uint64_t& hash) const override {
+    void update_xxHash_with_value(size_t start, size_t end, uint64_t& hash,
+                                  const uint8_t* __restrict null_data) const override {
         auto real_data = data->get_data_at(0);
         if (real_data.data == nullptr) {
             hash = HashUtil::xxHash64NullWithSeed(hash);
@@ -144,8 +145,9 @@ public:
         }
     }
 
-    void update_crc_with_value(size_t n, uint64_t& crc) const override {
-        get_data_column_ptr()->update_crc_with_value(n, crc);
+    void update_crc_with_value(size_t start, size_t end, uint64_t& hash,
+                               const uint8_t* __restrict null_data) const override {
+        get_data_column_ptr()->update_crc_with_value(start, end, hash, nullptr);
     }
 
     ColumnPtr filter(const Filter& filt, ssize_t result_size_hint) const override;
diff --git a/be/src/vec/columns/column_decimal.cpp b/be/src/vec/columns/column_decimal.cpp
index 78e7d055cb..4faa3fa490 100644
--- a/be/src/vec/columns/column_decimal.cpp
+++ b/be/src/vec/columns/column_decimal.cpp
@@ -128,16 +128,27 @@ void ColumnDecimal<T>::update_hashes_with_value(std::vector<SipHash>& hashes,
 }
 
 template <typename T>
-void ColumnDecimal<T>::update_crc_with_value(size_t n, uint64_t& crc) const {
-    if constexpr (!IsDecimalV2<T>) {
-        crc = HashUtil::zlib_crc_hash(&data[n], sizeof(T), crc);
+void ColumnDecimal<T>::update_crc_with_value(size_t start, size_t end, uint64_t& hash,
+                                             const uint8_t* __restrict null_data) const {
+    if (null_data == nullptr) {
+        for (size_t i = start; i < end; i++) {
+            if constexpr (!IsDecimalV2<T>) {
+                hash = HashUtil::zlib_crc_hash(&data[i], sizeof(T), hash);
+            } else {
+                decimalv2_do_crc(i, hash);
+            }
+        }
     } else {
-        const DecimalV2Value& dec_val = (const DecimalV2Value&)data[n];
-        int64_t int_val = dec_val.int_value();
-        int32_t frac_val = dec_val.frac_value();
-        crc = HashUtil::zlib_crc_hash(&int_val, sizeof(int_val), crc);
-        crc = HashUtil::zlib_crc_hash(&frac_val, sizeof(frac_val), crc);
-    };
+        for (size_t i = start; i < end; i++) {
+            if (null_data[i] == 0) {
+                if constexpr (!IsDecimalV2<T>) {
+                    hash = HashUtil::zlib_crc_hash(&data[i], sizeof(T), hash);
+                } else {
+                    decimalv2_do_crc(i, hash);
+                }
+            }
+        }
+    }
 }
 
 template <typename T>
@@ -150,19 +161,32 @@ void ColumnDecimal<T>::update_crcs_with_value(std::vector<uint64_t>& hashes, Pri
     } else {
         if (null_data == nullptr) {
             for (size_t i = 0; i < s; i++) {
-                update_crc_with_value(i, hashes[i]);
+                decimalv2_do_crc(i, hashes[i]);
             }
         } else {
             for (size_t i = 0; i < s; i++) {
-                if (null_data[i] == 0) update_crc_with_value(i, hashes[i]);
+                if (null_data[i] == 0) decimalv2_do_crc(i, hashes[i]);
             }
         }
     }
 }
 
 template <typename T>
-void ColumnDecimal<T>::update_xxHash_with_value(size_t n, uint64_t& hash) const {
-    hash = HashUtil::xxHash64WithSeed(reinterpret_cast<const char*>(&data[n]), sizeof(T), hash);
+void ColumnDecimal<T>::update_xxHash_with_value(size_t start, size_t end, uint64_t& hash,
+                                                const uint8_t* __restrict null_data) const {
+    if (null_data) {
+        for (size_t i = start; i < end; i++) {
+            if (null_data[i] == 0) {
+                hash = HashUtil::xxHash64WithSeed(reinterpret_cast<const char*>(&data[i]),
+                                                  sizeof(T), hash);
+            }
+        }
+    } else {
+        for (size_t i = start; i < end; i++) {
+            hash = HashUtil::xxHash64WithSeed(reinterpret_cast<const char*>(&data[i]), sizeof(T),
+                                              hash);
+        }
+    }
 }
 
 template <typename T>
diff --git a/be/src/vec/columns/column_decimal.h b/be/src/vec/columns/column_decimal.h
index 8968ff6017..ac3bd7456f 100644
--- a/be/src/vec/columns/column_decimal.h
+++ b/be/src/vec/columns/column_decimal.h
@@ -159,8 +159,10 @@ public:
                                   const uint8_t* __restrict null_data) const override;
     void update_crcs_with_value(std::vector<uint64_t>& hashes, PrimitiveType type,
                                 const uint8_t* __restrict null_data) const override;
-    void update_xxHash_with_value(size_t n, uint64_t& hash) const override;
-    void update_crc_with_value(size_t n, uint64_t& crc) const override;
+    void update_xxHash_with_value(size_t start, size_t end, uint64_t& hash,
+                                  const uint8_t* __restrict null_data) const override;
+    void update_crc_with_value(size_t start, size_t end, uint64_t& hash,
+                               const uint8_t* __restrict null_data) const override;
 
     int compare_at(size_t n, size_t m, const IColumn& rhs_, int nan_direction_hint) const override;
     void get_permutation(bool reverse, size_t limit, int nan_direction_hint,
@@ -265,6 +267,14 @@ protected:
             std::partial_sort(res.begin(), sort_end, res.end(),
                               [this](size_t a, size_t b) { return data[a] < data[b]; });
     }
+
+    void ALWAYS_INLINE decimalv2_do_crc(size_t i, uint64_t& hash) const {
+        const DecimalV2Value& dec_val = (const DecimalV2Value&)data[i];
+        int64_t int_val = dec_val.int_value();
+        int32_t frac_val = dec_val.frac_value();
+        hash = HashUtil::zlib_crc_hash(&int_val, sizeof(int_val), hash);
+        hash = HashUtil::zlib_crc_hash(&frac_val, sizeof(frac_val), hash);
+    };
 };
 
 template <typename>
diff --git a/be/src/vec/columns/column_nullable.cpp b/be/src/vec/columns/column_nullable.cpp
index 0e90251343..2b8632f8ec 100644
--- a/be/src/vec/columns/column_nullable.cpp
+++ b/be/src/vec/columns/column_nullable.cpp
@@ -114,21 +114,35 @@ void ColumnNullable::update_hashes_with_value(uint64_t* __restrict hashes,
     }
 }
 
-void ColumnNullable::update_xxHash_with_value(size_t n, uint64_t& hash) const {
-    auto* __restrict real_null_data = assert_cast<const ColumnUInt8&>(*null_map).get_data().data();
-    if (real_null_data[n] != 0) {
-        hash = HashUtil::xxHash64NullWithSeed(hash);
+void ColumnNullable::update_xxHash_with_value(size_t start, size_t end, uint64_t& hash,
+                                              const uint8_t* __restrict null_data) const {
+    if (!has_null()) {
+        nested_column->update_xxHash_with_value(start, end, hash, nullptr);
     } else {
-        nested_column->update_xxHash_with_value(n, hash);
+        auto* __restrict real_null_data =
+                assert_cast<const ColumnUInt8&>(*null_map).get_data().data();
+        for (int i = start; i < end; ++i) {
+            if (real_null_data[i] != 0) {
+                hash = HashUtil::xxHash64NullWithSeed(hash);
+            }
+        }
+        nested_column->update_xxHash_with_value(start, end, hash, real_null_data);
     }
 }
 
-void ColumnNullable::update_crc_with_value(size_t n, uint64_t& crc) const {
-    auto* __restrict real_null_data = assert_cast<const ColumnUInt8&>(*null_map).get_data().data();
-    if (real_null_data[n] != 0) {
-        crc = HashUtil::zlib_crc_hash_null(crc);
+void ColumnNullable::update_crc_with_value(size_t start, size_t end, uint64_t& hash,
+                                           const uint8_t* __restrict null_data) const {
+    if (!has_null()) {
+        nested_column->update_crc_with_value(start, end, hash, nullptr);
     } else {
-        nested_column->update_xxHash_with_value(n, crc);
+        auto* __restrict real_null_data =
+                assert_cast<const ColumnUInt8&>(*null_map).get_data().data();
+        for (int i = start; i < end; ++i) {
+            if (real_null_data[i] != 0) {
+                hash = HashUtil::zlib_crc_hash_null(hash);
+            }
+        }
+        nested_column->update_crc_with_value(start, end, hash, real_null_data);
     }
 }
 
diff --git a/be/src/vec/columns/column_nullable.h b/be/src/vec/columns/column_nullable.h
index 9f29965a32..1285f0c5e8 100644
--- a/be/src/vec/columns/column_nullable.h
+++ b/be/src/vec/columns/column_nullable.h
@@ -186,8 +186,10 @@ public:
                                 const uint8_t* __restrict null_data) const override;
     void update_hashes_with_value(uint64_t* __restrict hashes,
                                   const uint8_t* __restrict null_data) const override;
-    void update_xxHash_with_value(size_t n, uint64_t& hash) const override;
-    void update_crc_with_value(size_t n, uint64_t& crc) const override;
+    void update_xxHash_with_value(size_t start, size_t end, uint64_t& hash,
+                                  const uint8_t* __restrict null_data) const override;
+    void update_crc_with_value(size_t start, size_t end, uint64_t& hash,
+                               const uint8_t* __restrict null_data) const override;
     void get_extremes(Field& min, Field& max) const override;
 
     MutableColumns scatter(ColumnIndex num_columns, const Selector& selector) const override {
diff --git a/be/src/vec/columns/column_string.h b/be/src/vec/columns/column_string.h
index b4caa7b985..10b3c1a36a 100644
--- a/be/src/vec/columns/column_string.h
+++ b/be/src/vec/columns/column_string.h
@@ -342,16 +342,42 @@ public:
         SIP_HASHES_FUNCTION_COLUMN_IMPL();
     }
 
-    void update_xxHash_with_value(size_t n, uint64_t& hash) const override {
-        size_t string_size = size_at(n);
-        size_t offset = offset_at(n);
-        hash = HashUtil::xxHash64WithSeed(reinterpret_cast<const char*>(&chars[offset]),
-                                          string_size, hash);
+    void update_xxHash_with_value(size_t start, size_t end, uint64_t& hash,
+                                  const uint8_t* __restrict null_data) const override {
+        if (null_data) {
+            for (size_t i = start; i < end; ++i) {
+                if (null_data[i] == 0) {
+                    size_t string_size = size_at(i);
+                    size_t offset = offset_at(i);
+                    hash = HashUtil::xxHash64WithSeed(reinterpret_cast<const char*>(&chars[offset]),
+                                                      string_size, hash);
+                }
+            }
+        } else {
+            for (size_t i = start; i < end; ++i) {
+                size_t string_size = size_at(i);
+                size_t offset = offset_at(i);
+                hash = HashUtil::xxHash64WithSeed(reinterpret_cast<const char*>(&chars[offset]),
+                                                  string_size, hash);
+            }
+        }
     }
 
-    void update_crc_with_value(size_t n, uint64_t& crc) const override {
-        auto data_ref = get_data_at(n);
-        crc = HashUtil::zlib_crc_hash(data_ref.data, data_ref.size, crc);
+    void update_crc_with_value(size_t start, size_t end, uint64_t& hash,
+                               const uint8_t* __restrict null_data) const override {
+        if (null_data) {
+            for (size_t i = start; i < end; ++i) {
+                if (null_data[i] == 0) {
+                    auto data_ref = get_data_at(i);
+                    hash = HashUtil::zlib_crc_hash(data_ref.data, data_ref.size, hash);
+                }
+            }
+        } else {
+            for (size_t i = start; i < end; ++i) {
+                auto data_ref = get_data_at(i);
+                hash = HashUtil::zlib_crc_hash(data_ref.data, data_ref.size, hash);
+            }
+        }
     }
 
     void update_crcs_with_value(std::vector<uint64_t>& hashes, PrimitiveType type,
diff --git a/be/src/vec/columns/column_vector.h b/be/src/vec/columns/column_vector.h
index 1c18e810b0..899be2b2fc 100644
--- a/be/src/vec/columns/column_vector.h
+++ b/be/src/vec/columns/column_vector.h
@@ -243,21 +243,49 @@ public:
                                      const uint8_t* null_map,
                                      size_t max_row_byte_size) const override;
 
-    void update_xxHash_with_value(size_t n, uint64_t& hash) const override {
-        hash = HashUtil::xxHash64WithSeed(reinterpret_cast<const char*>(&data[n]), sizeof(T), hash);
+    void update_xxHash_with_value(size_t start, size_t end, uint64_t& hash,
+                                  const uint8_t* __restrict null_data) const override {
+        if (null_data) {
+            for (size_t i = start; i < end; i++) {
+                if (null_data[i] == 0) {
+                    hash = HashUtil::xxHash64WithSeed(reinterpret_cast<const char*>(&data[i]),
+                                                      sizeof(T), hash);
+                }
+            }
+        } else {
+            for (size_t i = start; i < end; i++) {
+                hash = HashUtil::xxHash64WithSeed(reinterpret_cast<const char*>(&data[i]),
+                                                  sizeof(T), hash);
+            }
+        }
     }
 
-    void update_crc_with_value(size_t n, uint64_t& crc) const override {
+    void ALWAYS_INLINE update_crc_with_value_without_null(size_t idx, uint64_t& hash) const {
         if constexpr (!std::is_same_v<T, Int64>) {
-            crc = HashUtil::zlib_crc_hash(&data[n], sizeof(T), crc);
+            hash = HashUtil::zlib_crc_hash(&data[idx], sizeof(T), hash);
         } else {
             if (this->is_date_type() || this->is_datetime_type()) {
                 char buf[64];
-                const VecDateTimeValue& date_val = (const VecDateTimeValue&)data[n];
+                const VecDateTimeValue& date_val = (const VecDateTimeValue&)data[idx];
                 auto len = date_val.to_buffer(buf);
-                crc = HashUtil::zlib_crc_hash(buf, len, crc);
+                hash = HashUtil::zlib_crc_hash(buf, len, hash);
             } else {
-                crc = HashUtil::zlib_crc_hash(&data[n], sizeof(T), crc);
+                hash = HashUtil::zlib_crc_hash(&data[idx], sizeof(T), hash);
+            }
+        }
+    }
+
+    void update_crc_with_value(size_t start, size_t end, uint64_t& hash,
+                               const uint8_t* __restrict null_data) const override {
+        if (null_data) {
+            for (size_t i = start; i < end; i++) {
+                if (null_data[i] == 0) {
+                    update_crc_with_value_without_null(i, hash);
+                }
+            }
+        } else {
+            for (size_t i = start; i < end; i++) {
+                update_crc_with_value_without_null(i, hash);
             }
         }
     }


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


[doris] 26/38: [feature](profile) backport stream load profile into 1.2-lts (#21784)

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 1aedb81b23925eb0424acc425a373cd43c7fe4cf
Author: Kaijie Chen <ck...@apache.org>
AuthorDate: Mon Jul 17 16:15:40 2023 +0800

    [feature](profile) backport stream load profile into 1.2-lts (#21784)
    
    Backport stream load profile into 1.2-lts, see #18364.
    
    The commented fields in proto is reserved for future backports.
---
 be/src/http/action/stream_load.cpp                            |  7 +++++++
 be/src/http/http_common.h                                     |  1 +
 be/src/runtime/fragment_mgr.cpp                               |  1 +
 .../main/java/org/apache/doris/planner/StreamLoadPlanner.java |  1 +
 .../src/main/java/org/apache/doris/qe/QeProcessorImpl.java    | 11 +++++++++--
 .../src/main/java/org/apache/doris/task/LoadTaskInfo.java     |  4 ++++
 .../src/main/java/org/apache/doris/task/StreamLoadTask.java   |  9 +++++++++
 gensrc/thrift/FrontendService.thrift                          |  6 ++++++
 8 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/be/src/http/action/stream_load.cpp b/be/src/http/action/stream_load.cpp
index 5f036374c2..b9f2700968 100644
--- a/be/src/http/action/stream_load.cpp
+++ b/be/src/http/action/stream_load.cpp
@@ -572,6 +572,13 @@ Status StreamLoadAction::_process_put(HttpRequest* http_req, StreamLoadContext*
             request.__set_trim_double_quotes(false);
         }
     }
+    if (!http_req->header(HTTP_ENABLE_PROFILE).empty()) {
+        if (iequal(http_req->header(HTTP_ENABLE_PROFILE), "true")) {
+            request.__set_enable_profile(true);
+        } else {
+            request.__set_enable_profile(false);
+        }
+    }
 
 #ifndef BE_TEST
     // plan this load
diff --git a/be/src/http/http_common.h b/be/src/http/http_common.h
index e61c828fb4..9c9dbf9296 100644
--- a/be/src/http/http_common.h
+++ b/be/src/http/http_common.h
@@ -52,6 +52,7 @@ static const std::string HTTP_SEND_BATCH_PARALLELISM = "send_batch_parallelism";
 static const std::string HTTP_LOAD_TO_SINGLE_TABLET = "load_to_single_tablet";
 static const std::string HTTP_HIDDEN_COLUMNS = "hidden_columns";
 static const std::string HTTP_TRIM_DOUBLE_QUOTES = "trim_double_quotes";
+static const std::string HTTP_ENABLE_PROFILE = "enable_profile";
 
 static const std::string HTTP_TWO_PHASE_COMMIT = "two_phase_commit";
 static const std::string HTTP_TXN_ID_KEY = "txn_id";
diff --git a/be/src/runtime/fragment_mgr.cpp b/be/src/runtime/fragment_mgr.cpp
index 2b069d78a2..3bed90a59e 100644
--- a/be/src/runtime/fragment_mgr.cpp
+++ b/be/src/runtime/fragment_mgr.cpp
@@ -327,6 +327,7 @@ void FragmentExecState::coordinator_callback(const Status& status, RuntimeProfil
 
     RuntimeState* runtime_state = _executor.runtime_state();
     DCHECK(runtime_state != nullptr);
+    params.__set_query_type(runtime_state->query_type());
     if (runtime_state->query_type() == TQueryType::LOAD && !done && status.ok()) {
         // this is a load plan, and load is not finished, just make a brief report
         params.__set_loaded_rows(runtime_state->num_rows_load_total());
diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/StreamLoadPlanner.java b/fe/fe-core/src/main/java/org/apache/doris/planner/StreamLoadPlanner.java
index 634379ed7d..c61fd96976 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/StreamLoadPlanner.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/StreamLoadPlanner.java
@@ -259,6 +259,7 @@ public class StreamLoadPlanner {
         queryOptions.setLoadMemLimit(taskInfo.getMemLimit());
         queryOptions.setEnableVectorizedEngine(Config.enable_vectorized_load);
         queryOptions.setBeExecVersion(Config.be_exec_version);
+        queryOptions.setIsReportSuccess(taskInfo.getEnableProfile());
 
         params.setQueryOptions(queryOptions);
         TQueryGlobals queryGlobals = new TQueryGlobals();
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/QeProcessorImpl.java b/fe/fe-core/src/main/java/org/apache/doris/qe/QeProcessorImpl.java
index 1bf11ece97..7e79fc47ae 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/QeProcessorImpl.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/QeProcessorImpl.java
@@ -24,6 +24,7 @@ import org.apache.doris.common.util.DebugUtil;
 import org.apache.doris.common.util.ProfileWriter;
 import org.apache.doris.metric.MetricRepo;
 import org.apache.doris.thrift.TNetworkAddress;
+import org.apache.doris.thrift.TQueryType;
 import org.apache.doris.thrift.TReportExecStatusParams;
 import org.apache.doris.thrift.TReportExecStatusResult;
 import org.apache.doris.thrift.TStatus;
@@ -188,8 +189,14 @@ public final class QeProcessorImpl implements QeProcessor {
         final TReportExecStatusResult result = new TReportExecStatusResult();
         final QueryInfo info = coordinatorMap.get(params.query_id);
         if (info == null) {
-            result.setStatus(new TStatus(TStatusCode.RUNTIME_ERROR));
-            LOG.info("ReportExecStatus() runtime error, query {} does not exist", DebugUtil.printId(params.query_id));
+            // There is no QueryInfo for StreamLoad, so we return OK
+            if (params.query_type == TQueryType.LOAD) {
+                result.setStatus(new TStatus(TStatusCode.OK));
+            } else {
+                result.setStatus(new TStatus(TStatusCode.RUNTIME_ERROR));
+            }
+            LOG.info("ReportExecStatus() runtime error, query {} with type {} does not exist",
+                    DebugUtil.printId(params.query_id), params.query_type);
             return result;
         }
         try {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/task/LoadTaskInfo.java b/fe/fe-core/src/main/java/org/apache/doris/task/LoadTaskInfo.java
index e384394653..47d18ef205 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/task/LoadTaskInfo.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/task/LoadTaskInfo.java
@@ -101,6 +101,10 @@ public interface LoadTaskInfo {
         return false;
     }
 
+    default boolean getEnableProfile() {
+        return false;
+    }
+
     class ImportColumnDescs {
         public List<ImportColumnDesc> descs = Lists.newArrayList();
         public boolean isColumnDescsRewrited = false;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/task/StreamLoadTask.java b/fe/fe-core/src/main/java/org/apache/doris/task/StreamLoadTask.java
index 2a80ceef90..cae47eca28 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/task/StreamLoadTask.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/task/StreamLoadTask.java
@@ -83,6 +83,7 @@ public class StreamLoadTask implements LoadTaskInfo {
     private String headerType = "";
     private List<String> hiddenColumns;
     private boolean trimDoubleQuotes = false;
+    private boolean enableProfile = false;
 
     public StreamLoadTask(TUniqueId id, long txnId, TFileType fileType, TFileFormatType formatType,
             TFileCompressType compressType) {
@@ -257,6 +258,11 @@ public class StreamLoadTask implements LoadTaskInfo {
         return trimDoubleQuotes;
     }
 
+    @Override
+    public boolean getEnableProfile() {
+        return enableProfile;
+    }
+
     public static StreamLoadTask fromTStreamLoadPutRequest(TStreamLoadPutRequest request) throws UserException {
         StreamLoadTask streamLoadTask = new StreamLoadTask(request.getLoadId(), request.getTxnId(),
                 request.getFileType(), request.getFormatType(),
@@ -359,6 +365,9 @@ public class StreamLoadTask implements LoadTaskInfo {
         if (request.isSetTrimDoubleQuotes()) {
             trimDoubleQuotes = request.isTrimDoubleQuotes();
         }
+        if (request.isSetEnableProfile()) {
+            enableProfile = request.isEnableProfile();
+        }
     }
 
     // used for stream load
diff --git a/gensrc/thrift/FrontendService.thrift b/gensrc/thrift/FrontendService.thrift
index 32c73a5663..3634a11333 100644
--- a/gensrc/thrift/FrontendService.thrift
+++ b/gensrc/thrift/FrontendService.thrift
@@ -407,6 +407,10 @@ struct TReportExecStatusParams {
   17: optional i64 loaded_bytes
 
   18: optional list<Types.TErrorTabletInfo> errorTabletInfos
+
+  // 19: optional i32 fragment_id
+
+  20: optional PaloInternalService.TQueryType query_type
 }
 
 struct TFeResult {
@@ -547,6 +551,8 @@ struct TStreamLoadPutRequest {
     40: optional PlanNodes.TFileCompressType compress_type
     41: optional i64 file_size // only for stream load with parquet or orc
     42: optional bool trim_double_quotes // trim double quotes for csv
+    // 43: optional i32 skip_lines // csv skip line num, only used when csv header_type is not set.
+    44: optional bool enable_profile
 }
 
 struct TStreamLoadPutResult {


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


[doris] 06/38: Delete alter system modify broker related documents in 1.2 (#21582)

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 334de9abd76fc4c7a29ac3f28d9838f8434535ba
Author: caoliang-web <71...@users.noreply.github.com>
AuthorDate: Thu Jul 6 18:52:39 2023 +0800

    Delete alter system modify broker related documents in 1.2 (#21582)
---
 .../ALTER-SYSTEM-MODIFY-BROKER.md                  | 38 ----------------------
 docs/sidebars.json                                 |  1 -
 .../ALTER-SYSTEM-MODIFY-BROKER.md                  | 38 ----------------------
 3 files changed, 77 deletions(-)

diff --git a/docs/en/docs/sql-manual/sql-reference/Cluster-Management-Statements/ALTER-SYSTEM-MODIFY-BROKER.md b/docs/en/docs/sql-manual/sql-reference/Cluster-Management-Statements/ALTER-SYSTEM-MODIFY-BROKER.md
deleted file mode 100644
index 6db1368d79..0000000000
--- a/docs/en/docs/sql-manual/sql-reference/Cluster-Management-Statements/ALTER-SYSTEM-MODIFY-BROKER.md
+++ /dev/null
@@ -1,38 +0,0 @@
----
-{
-    "title": "ALTER-SYSTEM-MODIFY-BROKER",
-    "language": "en"
-}
----
-
-<!--
-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.
--->
-
-## ALTER-SYSTEM-MODIFY-BROKER
-
-### Description
-
-### Example
-
-### Keywords
-
-    ALTER, SYSTEM, MODIFY, BROKER, ALTER SYSTEM
-
-### Best Practice
-
diff --git a/docs/sidebars.json b/docs/sidebars.json
index c543983e05..cdaefc289e 100644
--- a/docs/sidebars.json
+++ b/docs/sidebars.json
@@ -757,7 +757,6 @@
                                 "sql-manual/sql-reference/Cluster-Management-Statements/ALTER-SYSTEM-ADD-OBSERVER",
                                 "sql-manual/sql-reference/Cluster-Management-Statements/ALTER-SYSTEM-MODIFY-BACKEND",
                                 "sql-manual/sql-reference/Cluster-Management-Statements/ALTER-SYSTEM-ADD-FOLLOWER",
-                                "sql-manual/sql-reference/Cluster-Management-Statements/ALTER-SYSTEM-MODIFY-BROKER",
                                 "sql-manual/sql-reference/Cluster-Management-Statements/ALTER-SYSTEM-ADD-BROKER",
                                 "sql-manual/sql-reference/Cluster-Management-Statements/ALTER-SYSTEM-ADD-BACKEND",
                                 "sql-manual/sql-reference/Cluster-Management-Statements/ALTER-SYSTEM-DROP-BACKEND"
diff --git a/docs/zh-CN/docs/sql-manual/sql-reference/Cluster-Management-Statements/ALTER-SYSTEM-MODIFY-BROKER.md b/docs/zh-CN/docs/sql-manual/sql-reference/Cluster-Management-Statements/ALTER-SYSTEM-MODIFY-BROKER.md
deleted file mode 100644
index fc3dffb2fb..0000000000
--- a/docs/zh-CN/docs/sql-manual/sql-reference/Cluster-Management-Statements/ALTER-SYSTEM-MODIFY-BROKER.md
+++ /dev/null
@@ -1,38 +0,0 @@
----
-{
-    "title": "ALTER-SYSTEM-MODIFY-BROKER",
-    "language": "zh-CN"
-}
----
-
-<!--
-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.
--->
-
-## ALTER-SYSTEM-MODIFY-BROKER
-
-### Description
-
-### Example
-
-### Keywords
-
-    ALTER, SYSTEM, MODIFY, BROKER, ALTER SYSTEM
-
-### Best Practice
-


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


[doris] 09/38: [Fix](storage)read page cache when seek #21272

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 eff5d9157ffb57be884b2d67839ef3d35752a7d1
Author: wangbo <wa...@apache.org>
AuthorDate: Wed Jun 28 15:53:40 2023 +0800

    [Fix](storage)read page cache when seek #21272
    
    Currently, when a columnIter is used for seek, then page cache is not set;
    When this colunIter is used for later read data, then page cache could not be used.
---
 be/src/olap/rowset/segment_v2/segment_iterator.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/be/src/olap/rowset/segment_v2/segment_iterator.cpp b/be/src/olap/rowset/segment_v2/segment_iterator.cpp
index 94fc3dfa5d..cb9dff43c1 100644
--- a/be/src/olap/rowset/segment_v2/segment_iterator.cpp
+++ b/be/src/olap/rowset/segment_v2/segment_iterator.cpp
@@ -289,6 +289,7 @@ Status SegmentIterator::_prepare_seek(const StorageReadOptions::KeyRange& key_ra
                                                           &_column_iterators[unique_id]));
             ColumnIteratorOptions iter_opts;
             iter_opts.stats = _opts.stats;
+            iter_opts.use_page_cache = _opts.use_page_cache;
             iter_opts.file_reader = _file_reader.get();
             iter_opts.io_ctx = _opts.io_ctx;
             RETURN_IF_ERROR(_column_iterators[unique_id]->init(iter_opts));


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


[doris] 13/38: [fix](multicatalog) fix protocol of reading data from cosn for hive/iceberg catalog (#21683)

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 545111d27a25913ac475b43e488092e5a6066590
Author: Yulei-Yang <yu...@gmail.com>
AuthorDate: Mon Jul 10 22:10:45 2023 +0800

    [fix](multicatalog) fix protocol of reading data from cosn for hive/iceberg catalog (#21683)
    
    Error msg:
    ERROR 1105 (HY000): errCode = 2, detailMessage = get file split failed for table: xxxx, err: org.apache.hadoop.fs.s3a.RemoteFileChangedException: open `s3a://xxx-bucket/xxx.db/xxx_table/dt=20230704/000000_0': Change reported by S3 during open at position 198924776. ETag e42667ea1cbdfcfacb46fa1627356bce was unavailable
    
    Reason: tencent cloud cosn(CHDFS) is not applicable accessed by s3 protocol, it's more like a hdfs system.
---
 .../java/org/apache/doris/common/FeConstants.java     |  1 +
 .../doris/datasource/hive/HiveMetaStoreCache.java     | 12 ++++++------
 .../doris/planner/external/HiveScanProvider.java      | 19 ++++++++++---------
 .../planner/external/iceberg/IcebergScanProvider.java | 19 ++++++++++---------
 4 files changed, 27 insertions(+), 24 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/FeConstants.java b/fe/fe-core/src/main/java/org/apache/doris/common/FeConstants.java
index 8d032b604a..91ad6e4a61 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/common/FeConstants.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/common/FeConstants.java
@@ -75,6 +75,7 @@ public class FeConstants {
     public static String FS_PREFIX_OSS = "oss";
     public static String FS_PREFIX_BOS = "bos";
     public static String FS_PREFIX_COS = "cos";
+    public static String FS_PREFIX_COSN = "cosn";
     public static String FS_PREFIX_OBS = "obs";
     public static String FS_PREFIX_OFS = "ofs";
     public static String FS_PREFIX_GFS = "gfs";
diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HiveMetaStoreCache.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HiveMetaStoreCache.java
index 8b7d7f83c6..778fb10262 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HiveMetaStoreCache.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HiveMetaStoreCache.java
@@ -311,12 +311,12 @@ public class HiveMetaStoreCache {
     // convert oss:// to s3://
     private String convertToS3IfNecessary(String location) {
         LOG.debug("try convert location to s3 prefix: " + location);
-        if (location.startsWith(FeConstants.FS_PREFIX_COS)
-                || location.startsWith(FeConstants.FS_PREFIX_BOS)
-                || location.startsWith(FeConstants.FS_PREFIX_BOS)
-                || location.startsWith(FeConstants.FS_PREFIX_OSS)
-                || location.startsWith(FeConstants.FS_PREFIX_S3A)
-                || location.startsWith(FeConstants.FS_PREFIX_S3N)) {
+        if ((location.startsWith(FeConstants.FS_PREFIX_COS)) && !(location.startsWith(FeConstants.FS_PREFIX_COSN))
+            || location.startsWith(FeConstants.FS_PREFIX_BOS)
+            || location.startsWith(FeConstants.FS_PREFIX_BOS)
+            || location.startsWith(FeConstants.FS_PREFIX_OSS)
+            || location.startsWith(FeConstants.FS_PREFIX_S3A)
+            || location.startsWith(FeConstants.FS_PREFIX_S3N)) {
             int pos = location.indexOf("://");
             if (pos == -1) {
                 throw new RuntimeException("No '://' found in location: " + location);
diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/external/HiveScanProvider.java b/fe/fe-core/src/main/java/org/apache/doris/planner/external/HiveScanProvider.java
index 9aa4ab6dc4..845d62f92c 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/external/HiveScanProvider.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/external/HiveScanProvider.java
@@ -112,16 +112,17 @@ public class HiveScanProvider extends HMSTableScanProvider {
     public TFileType getLocationType() throws DdlException, MetaNotFoundException {
         String location = hmsTable.getRemoteTable().getSd().getLocation();
         if (location != null && !location.isEmpty()) {
-            if (location.startsWith(FeConstants.FS_PREFIX_S3)
-                    || location.startsWith(FeConstants.FS_PREFIX_S3A)
-                    || location.startsWith(FeConstants.FS_PREFIX_S3N)
-                    || location.startsWith(FeConstants.FS_PREFIX_BOS)
-                    || location.startsWith(FeConstants.FS_PREFIX_COS)
-                    || location.startsWith(FeConstants.FS_PREFIX_OSS)
-                    || location.startsWith(FeConstants.FS_PREFIX_OBS)) {
-                return TFileType.FILE_S3;
-            } else if (location.startsWith(FeConstants.FS_PREFIX_HDFS)) {
+            if (location.startsWith(FeConstants.FS_PREFIX_HDFS)
+                || location.startsWith(FeConstants.FS_PREFIX_COSN)) {
                 return TFileType.FILE_HDFS;
+            } else if (location.startsWith(FeConstants.FS_PREFIX_S3)
+                || location.startsWith(FeConstants.FS_PREFIX_S3A)
+                || location.startsWith(FeConstants.FS_PREFIX_S3N)
+                || location.startsWith(FeConstants.FS_PREFIX_BOS)
+                || location.startsWith(FeConstants.FS_PREFIX_COS)
+                || location.startsWith(FeConstants.FS_PREFIX_OSS)
+                || location.startsWith(FeConstants.FS_PREFIX_OBS)) {
+                return TFileType.FILE_S3;
             } else if (location.startsWith(FeConstants.FS_PREFIX_FILE)) {
                 return TFileType.FILE_LOCAL;
             } else if (location.startsWith(FeConstants.FS_PREFIX_OFS)) {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/external/iceberg/IcebergScanProvider.java b/fe/fe-core/src/main/java/org/apache/doris/planner/external/iceberg/IcebergScanProvider.java
index 970dc97800..e8295a3fc3 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/external/iceberg/IcebergScanProvider.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/external/iceberg/IcebergScanProvider.java
@@ -117,16 +117,17 @@ public class IcebergScanProvider extends QueryScanProvider {
     public TFileType getLocationType() throws DdlException, MetaNotFoundException {
         String location = icebergSource.getIcebergTable().location();
         if (location != null && !location.isEmpty()) {
-            if (location.startsWith(FeConstants.FS_PREFIX_S3)
-                    || location.startsWith(FeConstants.FS_PREFIX_S3A)
-                    || location.startsWith(FeConstants.FS_PREFIX_S3N)
-                    || location.startsWith(FeConstants.FS_PREFIX_BOS)
-                    || location.startsWith(FeConstants.FS_PREFIX_COS)
-                    || location.startsWith(FeConstants.FS_PREFIX_OSS)
-                    || location.startsWith(FeConstants.FS_PREFIX_OBS)) {
-                return TFileType.FILE_S3;
-            } else if (location.startsWith(FeConstants.FS_PREFIX_HDFS)) {
+            if (location.startsWith(FeConstants.FS_PREFIX_HDFS)
+                || location.startsWith(FeConstants.FS_PREFIX_COSN)) {
                 return TFileType.FILE_HDFS;
+            } else if (location.startsWith(FeConstants.FS_PREFIX_S3)
+                || location.startsWith(FeConstants.FS_PREFIX_S3A)
+                || location.startsWith(FeConstants.FS_PREFIX_S3N)
+                || location.startsWith(FeConstants.FS_PREFIX_BOS)
+                || location.startsWith(FeConstants.FS_PREFIX_COS)
+                || location.startsWith(FeConstants.FS_PREFIX_OSS)
+                || location.startsWith(FeConstants.FS_PREFIX_OBS)) {
+                return TFileType.FILE_S3;
             } else if (location.startsWith(FeConstants.FS_PREFIX_FILE)) {
                 return TFileType.FILE_LOCAL;
             } else if (location.startsWith(FeConstants.FS_PREFIX_OFS)) {


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


[doris] 17/38: [enhancement](mysql) Add have_query_cache variable to be compatible with old mysql client (#21710)

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 c700b7c516c65d3ec8dabb147530be4aaeaaf204
Author: zy-kkk <zh...@gmail.com>
AuthorDate: Tue Jul 11 13:10:58 2023 +0800

    [enhancement](mysql) Add have_query_cache variable to be compatible with old mysql client (#21710)
---
 docs/en/docs/advanced/variables.md                                | 4 ++++
 docs/zh-CN/docs/advanced/variables.md                             | 4 ++++
 fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java | 8 ++++++++
 3 files changed, 16 insertions(+)

diff --git a/docs/en/docs/advanced/variables.md b/docs/en/docs/advanced/variables.md
index bca47193bd..27769a6fae 100644
--- a/docs/en/docs/advanced/variables.md
+++ b/docs/en/docs/advanced/variables.md
@@ -177,6 +177,10 @@ Note that the comment must start with /*+ and can only follow the SELECT.
 
     Used for compatibility with MySQL clients. No practical effect.
 
+* `have_query_cache`
+
+  Used for compatibility with MySQL clients. No practical effect.
+
 * `default_order_by_limit`
 
   Used to control the default number of items returned after OrderBy. The default value is -1, and the maximum number of records after the query is returned by default, and the upper limit is the MAX_VALUE of the long data type.
diff --git a/docs/zh-CN/docs/advanced/variables.md b/docs/zh-CN/docs/advanced/variables.md
index 81b74850a9..939f69b6c2 100644
--- a/docs/zh-CN/docs/advanced/variables.md
+++ b/docs/zh-CN/docs/advanced/variables.md
@@ -175,6 +175,10 @@ SELECT /*+ SET_VAR(query_timeout = 1, enable_partition_cache=true) */ sleep(3);
 
   用于兼容 MySQL 客户端。无实际作用。
 
+- `have_query_cache`
+
+  用于兼容 MySQL 客户端。无实际作用。
+
 - `default_order_by_limit`
 
   用于控制 OrderBy 以后返回的默认条数。默认值为 -1,默认返回查询后的最大条数,上限为 long 数据类型的 MAX_VALUE 值。
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 a57b3e542e..83e55452bf 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
@@ -80,6 +80,7 @@ public class SessionVariable implements Serializable, Writable {
     public static final String SQL_SAFE_UPDATES = "sql_safe_updates";
     public static final String NET_BUFFER_LENGTH = "net_buffer_length";
     public static final String CODEGEN_LEVEL = "codegen_level";
+    public static final String HAVE_QUERY_CACHE =  "have_query_cache";
     // mem limit can't smaller than bufferpool's default page size
     public static final int MIN_EXEC_MEM_LIMIT = 2097152;
     public static final String BATCH_SIZE = "batch_size";
@@ -398,6 +399,9 @@ public class SessionVariable implements Serializable, Writable {
     @VariableMgr.VarAttr(name = CODEGEN_LEVEL)
     public int codegenLevel = 0;
 
+    @VariableMgr.VarAttr(name = HAVE_QUERY_CACHE, flag = VariableMgr.READ_ONLY)
+    public boolean haveQueryCache = false;
+
     // 4096 minus 16 + 16 bytes padding that in padding pod array
     @VariableMgr.VarAttr(name = BATCH_SIZE)
     public int batchSize = 4064;
@@ -879,6 +883,10 @@ public class SessionVariable implements Serializable, Writable {
         return codegenLevel;
     }
 
+    public boolean getHaveQueryCache() {
+        return haveQueryCache;
+    }
+
     /**
      * setMaxExecMemByte.
      **/


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


[doris] 01/38: [branch-1.2][Fix](planner)replace limit to -1 if is Long.MAX_VALUE (#21521)

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 8106524d1e38033214e2e5b9f0773acc189c595b
Author: mch_ucchi <41...@users.noreply.github.com>
AuthorDate: Wed Jul 5 15:40:53 2023 +0800

    [branch-1.2][Fix](planner)replace limit to -1 if is Long.MAX_VALUE (#21521)
    
    sqlSelectLimit is Long.MAX_VALUE default, we replace it to -1 to eliminate limit, then data will no be gathered to one node.
---
 .../src/main/java/org/apache/doris/planner/SingleNodePlanner.java | 8 ++++++--
 fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java | 2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/SingleNodePlanner.java b/fe/fe-core/src/main/java/org/apache/doris/planner/SingleNodePlanner.java
index ef080ba6ab..a145b6e9f1 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/SingleNodePlanner.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/SingleNodePlanner.java
@@ -302,7 +302,11 @@ public class SingleNodePlanner {
                 if (sqlSelectLimit > -1) {
                     newDefaultOrderByLimit = Math.min(newDefaultOrderByLimit, sqlSelectLimit);
                 }
-                root.setLimit(limit != -1 ? limit : newDefaultOrderByLimit);
+                if (newDefaultOrderByLimit == Long.MAX_VALUE) {
+                    root.setLimit(limit);
+                } else {
+                    root.setLimit(limit != -1 ? limit : newDefaultOrderByLimit);
+                }
             } else {
                 root.setLimit(limit);
             }
@@ -312,7 +316,7 @@ public class SingleNodePlanner {
             // from SelectStmt outside
             root = addUnassignedConjuncts(analyzer, root);
         } else {
-            if (!stmt.hasLimit()) {
+            if (!stmt.hasLimit() && sqlSelectLimit < Long.MAX_VALUE) {
                 root.setLimitAndOffset(sqlSelectLimit, stmt.getOffset());
             } else {
                 root.setLimitAndOffset(stmt.getLimit(), stmt.getOffset());
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 2b87524107..a57b3e542e 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
@@ -351,7 +351,7 @@ public class SessionVariable implements Serializable, Writable {
     public boolean sqlAutoIsNull = false;
 
     @VariableMgr.VarAttr(name = SQL_SELECT_LIMIT)
-    public long sqlSelectLimit = 9223372036854775807L;
+    public long sqlSelectLimit = -1;
 
     // this is used to make c3p0 library happy
     @VariableMgr.VarAttr(name = MAX_ALLOWED_PACKET)


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


[doris] 29/38: [performance](group_concat) avoid extra copy in group_concat (#21880)

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 85b077e32c54af01e247c22b2762ff0acfe1cf9a
Author: Mryange <59...@users.noreply.github.com>
AuthorDate: Tue Jul 18 00:02:26 2023 +0800

    [performance](group_concat) avoid extra copy in group_concat (#21880)
    
    pick from #21432
---
 be/src/vec/aggregate_functions/aggregate_function_group_concat.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/be/src/vec/aggregate_functions/aggregate_function_group_concat.h b/be/src/vec/aggregate_functions/aggregate_function_group_concat.h
index 33c83fc7b0..fde7ef864d 100644
--- a/be/src/vec/aggregate_functions/aggregate_function_group_concat.h
+++ b/be/src/vec/aggregate_functions/aggregate_function_group_concat.h
@@ -58,7 +58,7 @@ struct AggregateFunctionGroupConcatData {
         }
     }
 
-    std::string get() const { return data; }
+    const std::string& get() const { return data; }
 
     void write(BufferWritable& buf) const {
         write_binary(data, buf);
@@ -132,7 +132,7 @@ public:
     }
 
     void insert_result_into(ConstAggregateDataPtr __restrict place, IColumn& to) const override {
-        std::string result = this->data(place).get();
+        const std::string& result = this->data(place).get();
         static_cast<ColumnString&>(to).insert_data(result.c_str(), result.length());
     }
 };


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


[doris] 31/38: [branch-1.2-lts](cherry-pick) enable strong consistency by syncing max journal… (#21804)

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 dbaf0964de518374af1c2d790d9e1afed5649fbb
Author: Siyang Tang <82...@users.noreply.github.com>
AuthorDate: Tue Jul 18 15:13:52 2023 +0800

    [branch-1.2-lts](cherry-pick) enable strong consistency by syncing max journal… (#21804)
    
    Add a session var & config enable_strong_consistency_read to solve the problem that loading result may be shortly invisible to follwers, to meet users requirements in strong consistency read scenario.
    
    Will sync max journal id from master and wait for replaying.
---
 docs/en/docs/advanced/variables.md                 |   4 +
 docs/zh-CN/docs/advanced/variables.md              |   5 +
 .../java/org/apache/doris/qe/MasterOpExecutor.java | 124 ++++++++++++++++-----
 .../java/org/apache/doris/qe/SessionVariable.java  |   5 +
 .../java/org/apache/doris/qe/StmtExecutor.java     |   9 ++
 .../apache/doris/service/FrontendServiceImpl.java  |   5 +
 gensrc/thrift/FrontendService.thrift               |   1 +
 7 files changed, 125 insertions(+), 28 deletions(-)

diff --git a/docs/en/docs/advanced/variables.md b/docs/en/docs/advanced/variables.md
index 27769a6fae..7152fa49bb 100644
--- a/docs/en/docs/advanced/variables.md
+++ b/docs/en/docs/advanced/variables.md
@@ -647,6 +647,10 @@ Translated with www.DeepL.com/Translator (free version)
     +--------------+
     ```
 
+* `enable_strong_consistency_read`
+
+  Used to enable strong consistent reading. By default, Doris supports strong consistency within the same session, that is, changes to data within the same session are visible in real time. If you want strong consistent reads between sessions, set this variable to true. 
+
 ***
 
 #### Supplementary instructions on statement execution timeout control
diff --git a/docs/zh-CN/docs/advanced/variables.md b/docs/zh-CN/docs/advanced/variables.md
index 939f69b6c2..2309389367 100644
--- a/docs/zh-CN/docs/advanced/variables.md
+++ b/docs/zh-CN/docs/advanced/variables.md
@@ -632,6 +632,11 @@ try (Connection conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:9030/
     | 10000000     |
     +--------------+
     ```
+ 
+* `enable_strong_consistency_read`
+
+  用以开启强一致读。Doris 默认支持同一个会话内的强一致性,即同一个会话内对数据的变更操作是实时可见的。如需要会话间的强一致读,则需将此变量设置为true。
+
 ***
 
 #### 关于语句执行超时控制的补充说明
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/MasterOpExecutor.java b/fe/fe-core/src/main/java/org/apache/doris/qe/MasterOpExecutor.java
index 57e4fe67aa..b3ccdf3bbe 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/MasterOpExecutor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/MasterOpExecutor.java
@@ -19,6 +19,7 @@ package org.apache.doris.qe;
 
 import org.apache.doris.analysis.RedirectStatus;
 import org.apache.doris.common.ClientPool;
+import org.apache.doris.common.DdlException;
 import org.apache.doris.common.telemetry.Telemetry;
 import org.apache.doris.thrift.FrontendService;
 import org.apache.doris.thrift.TMasterOpRequest;
@@ -26,11 +27,13 @@ import org.apache.doris.thrift.TMasterOpResult;
 import org.apache.doris.thrift.TNetworkAddress;
 import org.apache.doris.thrift.TUniqueId;
 
+import com.google.common.collect.ImmutableMap;
 import io.opentelemetry.api.trace.Span;
 import io.opentelemetry.context.Context;
 import io.opentelemetry.context.Scope;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
+import org.apache.thrift.TException;
 import org.apache.thrift.transport.TTransportException;
 
 import java.nio.ByteBuffer;
@@ -63,24 +66,40 @@ public class MasterOpExecutor {
         this.shouldNotRetry = !isQuery;
     }
 
+    /**
+     * used for simply syncing journal with master under strong consistency mode
+     */
+    public MasterOpExecutor(ConnectContext ctx) {
+        this(null, ctx, RedirectStatus.FORWARD_WITH_SYNC, true);
+    }
+
     public void execute() throws Exception {
         Span forwardSpan =
                 ctx.getTracer().spanBuilder("forward").setParent(Context.current())
                         .startSpan();
-        try (Scope scope = forwardSpan.makeCurrent()) {
-            forward();
+        try (Scope ignored = forwardSpan.makeCurrent()) {
+            result = forward(buildStmtForwardParams());
         } catch (Exception e) {
             forwardSpan.recordException(e);
             throw e;
         } finally {
             forwardSpan.end();
         }
+        waitOnReplaying();
+    }
+
+    public void syncJournal() throws Exception {
+        result = forward(buildSyncJournalParmas());
+        waitOnReplaying();
+    }
+
+    private void waitOnReplaying() throws DdlException {
         LOG.info("forwarding to master get result max journal id: {}", result.maxJournalId);
         ctx.getEnv().getJournalObservable().waitOn(result.maxJournalId, waitTimeoutMs);
     }
 
     // Send request to Master
-    private void forward() throws Exception {
+    private TMasterOpResult forward(TMasterOpRequest params) throws Exception {
         if (!ctx.getEnv().isReady()) {
             throw new Exception("Node catalog is not ready, please wait for a while.");
         }
@@ -95,7 +114,50 @@ public class MasterOpExecutor {
             // may throw NullPointerException. add err msg
             throw new Exception("Failed to get master client.", e);
         }
+        final StringBuilder forwardMsg = new StringBuilder(String.format("forward to Master %s", thriftAddress));
+        if (!params.isSyncJournalOnly()) {
+            forwardMsg.append(", statement: %s").append(ctx.getStmtId());
+        }
+        LOG.info(forwardMsg.toString());
+
+        boolean isReturnToPool = false;
+        try {
+            final TMasterOpResult result = client.forward(params);
+            isReturnToPool = true;
+            return result;
+        } catch (TTransportException e) {
+            // wrap the raw exception.
+            forwardMsg.append(" : failed");
+            Exception exception = new ForwardToMasterException(String.format(forwardMsg.toString()), e);
+
+            boolean ok = ClientPool.frontendPool.reopen(client, thriftTimeoutMs);
+            if (!ok) {
+                throw exception;
+            }
+            if (shouldNotRetry || e.getType() == TTransportException.TIMED_OUT) {
+                throw exception;
+            } else {
+                LOG.warn(forwardMsg.append(" twice").toString(), e);
+                try {
+                    TMasterOpResult result = client.forward(params);
+                    isReturnToPool = true;
+                    return result;
+                } catch (TException ex) {
+                    throw exception;
+                }
+            }
+        } finally {
+            if (isReturnToPool) {
+                ClientPool.frontendPool.returnObject(thriftAddress, client);
+            } else {
+                ClientPool.frontendPool.invalidateObject(thriftAddress, client);
+            }
+        }
+    }
+
+    private TMasterOpRequest buildStmtForwardParams() {
         TMasterOpRequest params = new TMasterOpRequest();
+        //node ident
         params.setCluster(ctx.getClusterName());
         params.setSql(originStmt.originStmt);
         params.setStmtIdx(originStmt.idx);
@@ -122,32 +184,14 @@ public class MasterOpExecutor {
         if (null != ctx.queryId()) {
             params.setQueryId(ctx.queryId());
         }
+        return params;
+    }
 
-        LOG.info("Forward statement {} to Master {}", ctx.getStmtId(), thriftAddress);
-
-        boolean isReturnToPool = false;
-        try {
-            result = client.forward(params);
-            isReturnToPool = true;
-        } catch (TTransportException e) {
-            boolean ok = ClientPool.frontendPool.reopen(client, thriftTimeoutMs);
-            if (!ok) {
-                throw e;
-            }
-            if (shouldNotRetry || e.getType() == TTransportException.TIMED_OUT) {
-                throw e;
-            } else {
-                LOG.warn("Forward statement " + ctx.getStmtId() + " to Master " + thriftAddress + " twice", e);
-                result = client.forward(params);
-                isReturnToPool = true;
-            }
-        } finally {
-            if (isReturnToPool) {
-                ClientPool.frontendPool.returnObject(thriftAddress, client);
-            } else {
-                ClientPool.frontendPool.invalidateObject(thriftAddress, client);
-            }
-        }
+    private TMasterOpRequest buildSyncJournalParmas() {
+        final TMasterOpRequest params = new TMasterOpRequest();
+        //node ident
+        params.setSyncJournalOnly(true);
+        return params;
     }
 
     public ByteBuffer getOutputPacket() {
@@ -190,4 +234,28 @@ public class MasterOpExecutor {
     public void setResult(TMasterOpResult result) {
         this.result = result;
     }
+
+    public static class ForwardToMasterException extends RuntimeException {
+
+        private static final Map<Integer, String> TYPE_MSG_MAP =
+                ImmutableMap.<Integer, String>builder()
+                        .put(TTransportException.UNKNOWN, "Unknown exception")
+                        .put(TTransportException.NOT_OPEN, "Connection is not open")
+                        .put(TTransportException.ALREADY_OPEN, "Connection has already opened up")
+                        .put(TTransportException.TIMED_OUT, "Connection timeout")
+                        .put(TTransportException.END_OF_FILE, "EOF")
+                        .put(TTransportException.CORRUPTED_DATA, "Corrupted data")
+                        .build();
+
+        private final String msg;
+
+        public ForwardToMasterException(String msg, TTransportException exception) {
+            this.msg = msg + ", cause: " + TYPE_MSG_MAP.get(exception.getType());
+        }
+
+        @Override
+        public String getMessage() {
+            return msg;
+        }
+    }
 }
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 83e55452bf..40dfa11e8e 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
@@ -262,6 +262,8 @@ public class SessionVariable implements Serializable, Writable {
     // fix replica to query. If num = 1, query the smallest replica, if 2 is the second smallest replica.
     public static final String USE_FIX_REPLICA = "use_fix_replica";
 
+    public static final String ENABLE_STRONG_CONSISTENCY = "enable_strong_consistency_read";
+
     // session origin value
     public Map<Field, String> sessionOriginValue = new HashMap<Field, String>();
     // check stmt is or not [select /*+ SET_VAR(...)*/ ...]
@@ -689,6 +691,9 @@ public class SessionVariable implements Serializable, Writable {
     @VariableMgr.VarAttr(name = USE_FIX_REPLICA)
     public int useFixReplica = -1;
 
+    @VariableMgr.VarAttr(name = ENABLE_STRONG_CONSISTENCY)
+    public boolean enableStrongConsistencyRead = false;
+
     // 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/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
index be97ec39b6..57d63b688c 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
@@ -627,6 +627,14 @@ public class StmtExecutor implements ProfileWriter {
         }
     }
 
+    private void syncJournalIfNeeded() throws Exception {
+        final Env env = context.getEnv();
+        if (env.isMaster() || !context.getSessionVariable().enableStrongConsistencyRead) {
+            return;
+        }
+        new MasterOpExecutor(context).syncJournal();
+    }
+
     /**
      * get variables in stmt.
      *
@@ -1091,6 +1099,7 @@ public class StmtExecutor implements ProfileWriter {
         }
 
         // handle selects that fe can do without be, so we can make sql tools happy, especially the setup step.
+        syncJournalIfNeeded();
         if (parsedStmt instanceof SelectStmt && ((SelectStmt) parsedStmt).getTableRefs().isEmpty()) {
             SelectStmt parsedSelectStmt = (SelectStmt) parsedStmt;
             if (handleSelectRequestInFe(parsedSelectStmt)) {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java b/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
index 638f172660..2c6ac8d11d 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
@@ -536,6 +536,11 @@ public class FrontendServiceImpl implements FrontendService.Iface {
                 throw new TException("request from invalid host was rejected.");
             }
         }
+        if (params.isSyncJournalOnly()) {
+            final TMasterOpResult result = new TMasterOpResult();
+            result.setMaxJournalId(Env.getCurrentEnv().getMaxJournalId());
+            return result;
+        }
 
         // add this log so that we can track this stmt
         LOG.debug("receive forwarded stmt {} from FE: {}", params.getStmtId(), clientAddr.getHostname());
diff --git a/gensrc/thrift/FrontendService.thrift b/gensrc/thrift/FrontendService.thrift
index 3634a11333..207f8fb058 100644
--- a/gensrc/thrift/FrontendService.thrift
+++ b/gensrc/thrift/FrontendService.thrift
@@ -441,6 +441,7 @@ struct TMasterOpRequest {
     19: optional map<string, string> session_variables
     20: optional bool foldConstantByBe
     21: optional map<string, string> trace_carrier
+    22: optional bool syncJournalOnly // if set to true, this request means to do nothing but just sync max journal id of master
 }
 
 struct TColumnDefinition {


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


[doris] 03/38: [Fix](multi-catalog) Fix hadoop short circuit reading can not enabled in some environments. (#21548)

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 510c928f6ccd9f428d01e7890cda1f1b70fcdf0f
Author: Qi Chen <ka...@gmail.com>
AuthorDate: Thu Jul 6 13:44:55 2023 +0800

    [Fix](multi-catalog) Fix hadoop short circuit reading can not enabled in some environments. (#21548)
    
    Merge #21516 to branch-1.2-lts.
    
    Fix hadoop short circuit reading can not enabled in some environments.
    - Revert #21430 because it will cause performance degradation issue.
    - Add `$HADOOP_CONF_DIR` to `$CLASSPATH`.
    - Remove empty `hdfs-site.xml`. Because in some environments it will cause hadoop short circuit reading can not enabled.
    - Copy the hadoop common native libs(which is copied from https://github.com/apache/doris-thirdparty/pull/98
    ) and add it to `LD_LIBRARY_PATH`. Because in some environments `LD_LIBRARY_PATH` doesn't contain hadoop common native libs, which will cause hadoop short circuit reading can not enabled.
---
 be/CMakeLists.txt                               |  1 -
 bin/start_be.sh                                 | 11 +++++++----
 bin/start_fe.sh                                 |  5 ++++-
 build.sh                                        |  2 --
 conf/hdfs-site.xml                              | 23 -----------------------
 docs/en/docs/lakehouse/multi-catalog/hive.md    | 13 +++++++------
 docs/zh-CN/docs/lakehouse/multi-catalog/hive.md | 17 +++++++++--------
 thirdparty/build-thirdparty.sh                  |  3 +++
 8 files changed, 30 insertions(+), 45 deletions(-)

diff --git a/be/CMakeLists.txt b/be/CMakeLists.txt
index 12621403fb..9307e018f0 100644
--- a/be/CMakeLists.txt
+++ b/be/CMakeLists.txt
@@ -951,7 +951,6 @@ install(FILES
     ${BASE_DIR}/../conf/be.conf
     ${BASE_DIR}/../conf/odbcinst.ini
     ${BASE_DIR}/../conf/asan_suppr.conf
-    ${BASE_DIR}/../conf/hdfs-site.xml
     DESTINATION ${OUTPUT_DIR}/conf)
 
 get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
diff --git a/bin/start_be.sh b/bin/start_be.sh
index e4bd71a940..a26241862b 100755
--- a/bin/start_be.sh
+++ b/bin/start_be.sh
@@ -102,15 +102,18 @@ if [[ -d "${DORIS_HOME}/lib/hadoop_hdfs/" ]]; then
     done
 fi
 
+if [[ -n "${HADOOP_CONF_DIR}" ]]; then
+    export DORIS_CLASSPATH="${HADOOP_CONF_DIR}:${DORIS_CLASSPATH}"
+fi
+
 # the CLASSPATH and LIBHDFS_OPTS is used for hadoop libhdfs
 # and conf/ dir so that hadoop libhdfs can read .xml config file in conf/
-if command -v hadoop >/dev/null 2>&1; then
-    HADOOP_SYSTEM_CLASSPATH="$(hadoop classpath --glob)"
-fi
-export CLASSPATH="${HADOOP_SYSTEM_CLASSPATH}:${DORIS_HOME}/conf/:${DORIS_CLASSPATH}"
+export CLASSPATH="${DORIS_HOME}/conf/:${DORIS_CLASSPATH}:${CLASSPATH}"
 # DORIS_CLASSPATH is for self-managed jni
 export DORIS_CLASSPATH="-Djava.class.path=${DORIS_CLASSPATH}"
 
+export LD_LIBRARY_PATH="${DORIS_HOME}/lib/hadoop_hdfs/native:${LD_LIBRARY_PATH}"
+
 jdk_version() {
     local java_cmd="${1}"
     local result
diff --git a/bin/start_fe.sh b/bin/start_fe.sh
index 5028baedaf..03b0e8e8d5 100755
--- a/bin/start_fe.sh
+++ b/bin/start_fe.sh
@@ -179,7 +179,10 @@ done
 # make sure the doris-fe.jar is at first order, so that some classed
 # with same qualified name can be loaded priority from doris-fe.jar
 CLASSPATH="${DORIS_FE_JAR}:${CLASSPATH}"
-export CLASSPATH="${CLASSPATH}:${DORIS_HOME}/lib:${DORIS_HOME}/conf"
+if [[ -n "${HADOOP_CONF_DIR}" ]]; then
+    CLASSPATH="${HADOOP_CONF_DIR}:${CLASSPATH}"
+fi
+export CLASSPATH="${DORIS_HOME}/conf:${CLASSPATH}:${DORIS_HOME}/lib"
 
 pidfile="${PID_DIR}/fe.pid"
 
diff --git a/build.sh b/build.sh
index 531ba4ea13..a7f46b018d 100755
--- a/build.sh
+++ b/build.sh
@@ -507,7 +507,6 @@ if [[ "${BUILD_FE}" -eq 1 ]]; then
     cp -r -p "${DORIS_HOME}/bin"/*_fe.sh "${DORIS_OUTPUT}/fe/bin"/
     cp -r -p "${DORIS_HOME}/conf/fe.conf" "${DORIS_OUTPUT}/fe/conf"/
     cp -r -p "${DORIS_HOME}/conf/ldap.conf" "${DORIS_OUTPUT}/fe/conf"/
-    cp -r -p "${DORIS_HOME}/conf"/*.xml "${DORIS_OUTPUT}/fe/conf"/
     cp -r -p "${DORIS_HOME}/conf/mysql_ssl_default_certificate" "${DORIS_OUTPUT}/fe/"/
     rm -rf "${DORIS_OUTPUT}/fe/lib"/*
     cp -r -p "${DORIS_HOME}/fe/fe-core/target/lib"/* "${DORIS_OUTPUT}/fe/lib"/
@@ -541,7 +540,6 @@ if [[ "${BUILD_BE}" -eq 1 ]]; then
 
     if [[ -d "${DORIS_THIRDPARTY}/installed/lib/hadoop_hdfs/" ]]; then
         cp -r -p "${DORIS_THIRDPARTY}/installed/lib/hadoop_hdfs/" "${DORIS_OUTPUT}/be/lib/"
-        rm -rf "${DORIS_OUTPUT}/be/lib/hadoop_hdfs/native/"
     fi
 
     if [[ "${BUILD_JAVA_UDF}" -eq 0 ]]; then
diff --git a/conf/hdfs-site.xml b/conf/hdfs-site.xml
deleted file mode 100644
index 32235bf8bc..0000000000
--- a/conf/hdfs-site.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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.
--->
-<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
-
-<!-- Put site-specific property overrides in this file. -->
-
-<configuration>
-</configuration>
diff --git a/docs/en/docs/lakehouse/multi-catalog/hive.md b/docs/en/docs/lakehouse/multi-catalog/hive.md
index f82df22ab7..1a269d6774 100644
--- a/docs/en/docs/lakehouse/multi-catalog/hive.md
+++ b/docs/en/docs/lakehouse/multi-catalog/hive.md
@@ -34,17 +34,18 @@ Besides Hive, many other systems, such as Iceberg and Hudi, use Hive Metastore t
 
 When connnecting to Hive, Doris:
 
-1. Supports Hive version 1/2/3;
-2. Supports both Managed Table and External Table;
-3. Can identify metadata of Hive, Iceberg, and Hudi stored in Hive Metastore;
-4. Supports Hive tables with data stored in JuiceFS, which can be used the same way as normal Hive tables (put `juicefs-hadoop-x.x.x.jar` in `fe/lib/` and `apache_hdfs_broker/lib/`).
-5. Supports Hive tables with data stored in CHDFS, which can be used the same way as normal Hive tables. Follow below steps to prepare doris environment:
+1. Need to put core-site.xml, hdfs-site.xml and hive-site.xml in the conf directory of FE and BE. First read the hadoop configuration file in the conf directory, and then read the related to the environment variable `HADOOP_CONF_DIR` configuration file.
+2. Supports Hive version 1/2/3;
+3. Supports both Managed Table and External Table;
+4. Can identify metadata of Hive, Iceberg, and Hudi stored in Hive Metastore;
+5. Supports Hive tables with data stored in JuiceFS, which can be used the same way as normal Hive tables (put `juicefs-hadoop-x.x.x.jar` in `fe/lib/` and `apache_hdfs_broker/lib/`).
+6. Supports Hive tables with data stored in CHDFS, which can be used the same way as normal Hive tables. Follow below steps to prepare doris environment:
     1. put chdfs_hadoop_plugin_network-x.x.jar in fe/lib/ and apache_hdfs_broker/lib/
     2. copy core-site.xml and hdfs-site.xml from hive cluster to fe/conf/ and apache_hdfs_broker/conf
 
 <version since="dev">
 
-6. Supports Hive / Iceberg tables with data stored in GooseFS(GFS), which can be used the same way as normal Hive tables. Follow below steps to prepare doris environment:
+7. Supports Hive / Iceberg tables with data stored in GooseFS(GFS), which can be used the same way as normal Hive tables. Follow below steps to prepare doris environment:
     1. put goosefs-x.x.x-client.jar in fe/lib/ and apache_hdfs_broker/lib/
     2. add extra properties 'fs.AbstractFileSystem.gfs.impl' = 'com.qcloud.cos.goosefs.hadoop.GooseFileSystem', 'fs.gfs.impl' = 'com.qcloud.cos.goosefs.hadoop.FileSystem' when creating catalog
 
diff --git a/docs/zh-CN/docs/lakehouse/multi-catalog/hive.md b/docs/zh-CN/docs/lakehouse/multi-catalog/hive.md
index 98d32b8631..6cc16bdbe1 100644
--- a/docs/zh-CN/docs/lakehouse/multi-catalog/hive.md
+++ b/docs/zh-CN/docs/lakehouse/multi-catalog/hive.md
@@ -30,19 +30,20 @@ under the License.
 
 除了 Hive 外,很多其他系统也会使用 Hive Metastore 存储元数据。所以通过 Hive Catalog,我们不仅能访问 Hive,也能访问使用 Hive Metastore 作为元数据存储的系统。如 Iceberg、Hudi 等。
 
-## 使用限制
-
-1. hive 支持 1/2/3 版本。
-2. 支持 Managed Table 和 External Table。
-3. 可以识别 Hive Metastore 中存储的 hive、iceberg、hudi 元数据。
-4. 支持数据存储在 Juicefs 上的 hive 表,用法如下(需要把juicefs-hadoop-x.x.x.jar放在 fe/lib/ 和 apache_hdfs_broker/lib/ 下)。
-5. 支持数据存储在 CHDFS 上的 hive 表。需配置环境:
+## 使用须知
+
+1. 将 core-site.xml,hdfs-site.xml 和 hive-site.xml  放到 FE 和 BE 的 conf 目录下。优先读取 conf 目录下的 hadoop 配置文件,再读取环境变量 `HADOOP_CONF_DIR` 的相关配置文件。 
+2. hive 支持 1/2/3 版本。
+3. 支持 Managed Table 和 External Table。
+4. 可以识别 Hive Metastore 中存储的 hive、iceberg、hudi 元数据。
+5. 支持数据存储在 Juicefs 上的 hive 表,用法如下(需要把juicefs-hadoop-x.x.x.jar放在 fe/lib/ 和 apache_hdfs_broker/lib/ 下)。
+6. 支持数据存储在 CHDFS 上的 hive 表。需配置环境:
    1. 把chdfs_hadoop_plugin_network-x.x.jar 放在 fe/lib/ 和 apache_hdfs_broker/lib/ 下
    2. 将 hive 所在 Hadoop 集群的 core-site.xml 和 hdfs-site.xml 复制到 fe/conf/ 和 apache_hdfs_broker/conf 目录下
 
 <version since="dev">
 
-6. 支持数据存在在 GooseFS(GFS) 上的 hive、iceberg表。需配置环境:
+7. 支持数据存在在 GooseFS(GFS) 上的 hive、iceberg表。需配置环境:
    1. 把 goosefs-x.x.x-client.jar 放在 fe/lib/ 和 apache_hdfs_broker/lib/ 下
    2. 创建 catalog 时增加属性:'fs.AbstractFileSystem.gfs.impl' = 'com.qcloud.cos.goosefs.hadoop.GooseFileSystem', 'fs.gfs.impl' = 'com.qcloud.cos.goosefs.hadoop.FileSystem'
    
diff --git a/thirdparty/build-thirdparty.sh b/thirdparty/build-thirdparty.sh
index 58b629654a..ac6850a094 100755
--- a/thirdparty/build-thirdparty.sh
+++ b/thirdparty/build-thirdparty.sh
@@ -1576,6 +1576,9 @@ build_hadoop_libs() {
     mkdir -p "${TP_INSTALL_DIR}/lib/hadoop_hdfs/"
     cp -r ./hadoop-dist/target/hadoop-libhdfs-3.3.4/* "${TP_INSTALL_DIR}/lib/hadoop_hdfs/"
     cp -r ./hadoop-dist/target/hadoop-libhdfs-3.3.4/include/hdfs.h "${TP_INSTALL_DIR}/include/hadoop_hdfs/"
+    rm -rf "${TP_INSTALL_DIR}/lib/hadoop_hdfs/native/*.a"
+    find ./hadoop-dist/target/hadoop-3.3.4/lib/native/ -type f ! -name '*.a' -exec cp {} "${TP_INSTALL_DIR}/lib/hadoop_hdfs/native/" \;
+    find ./hadoop-dist/target/hadoop-3.3.4/lib/native/ -type l -exec cp -P {} "${TP_INSTALL_DIR}/lib/hadoop_hdfs/native/" \;
 }
 
 if [[ "${#packages[@]}" -eq 0 ]]; then


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


[doris] 37/38: [fix](planner)only forbid literal value in AnalyticExpr's order by list (#21820)

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 51faa95eeb26a03fa3996daddd65900c325916bb
Author: starocean999 <40...@users.noreply.github.com>
AuthorDate: Wed Jul 19 13:54:39 2023 +0800

    [fix](planner)only forbid literal value in AnalyticExpr's order by list (#21820)
    
    pick from master https://github.com/apache/doris/pull/21819
    
    The original error is the window function's order by clause doesn't support a literal value. But we use Expr's isConstant method to check if it's an literal, this is wrong. So the pr uses the correct method( isLiteral ) to check if an expr is literal to solve this problem
    
    ```sql
    select
        sortNum,
        BITMAP_UNION_COUNT (c.pv) over (ORDER BY **sortNum** ) totalNum
    from(
    select
        ifnull(a.sortNum, b.sortNum) sortNum,
        BITMAP_UNION (ifnull(a.c_pv, b.c_pv)) pv
    from
        (select **_1 sortNum_**, c_pv from ${tableName2} t where t.c_int = 1) a
    full join
        (select **_2 sortNum_**, c_pv from ${tableName2} t where t.c_int = 2) b
        on a.sortNum = b.sortNum
    GROUP BY
        sortNum
    ORDER BY
        sortNum
    ```
---
 fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticExpr.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticExpr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticExpr.java
index f5f1aa5397..8892cf9291 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticExpr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticExpr.java
@@ -478,7 +478,7 @@ public class AnalyticExpr extends Expr {
         type = getFnCall().getType();
 
         for (Expr e : partitionExprs) {
-            if (e.isConstant()) {
+            if (e.isLiteral()) {
                 throw new AnalysisException(
                     "Expressions in the PARTITION BY clause must not be constant: "
                     + e.toSql() + " (in " + toSql() + ")");
@@ -486,7 +486,7 @@ public class AnalyticExpr extends Expr {
         }
 
         for (OrderByElement e : orderByElements) {
-            if (e.getExpr().isConstant()) {
+            if (e.getExpr().isLiteral()) {
                 throw new AnalysisException(
                     "Expressions in the ORDER BY clause must not be constant: "
                             + e.getExpr().toSql() + " (in " + toSql() + ")");


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


[doris] 02/38: [fix](backup) fix show snapshot cauing mysql connection lost (#21520)

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 79f81a704a3f366b1c8277b6c72dc4d62209e1dd
Author: Mingyu Chen <mo...@163.com>
AuthorDate: Wed Jul 5 22:44:57 2023 +0800

    [fix](backup) fix show snapshot cauing mysql connection lost (#21520)
    
    If this is no `info file` in repository, the mysql connection may lost when user executing `show snapshot on repo`,
    ```
    2023-07-05 09:22:48,689 WARN (mysql-nio-pool-0|199) [ReadListener.lambda$handleEvent$0():60] Exception happened in one session(org.apache.doris.qe.ConnectContext@730797c1).
    java.io.IOException: Error happened when receiving packet.
        at org.apache.doris.qe.ConnectProcessor.processOnce(ConnectProcessor.java:691) ~[doris-fe.jar:1.2-SNAPSHOT]
        at org.apache.doris.mysql.ReadListener.lambda$handleEvent$0(ReadListener.java:52) ~[doris-fe.jar:1.2-SNAPSHOT]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[?:1.8.0_322]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[?:1.8.0_322]
        at java.lang.Thread.run(Thread.java:750) ~[?:1.8.0_322]
    ```
    
    This is because there are some field missing in returned result set.
---
 fe/fe-core/src/main/java/org/apache/doris/backup/Repository.java | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/backup/Repository.java b/fe/fe-core/src/main/java/org/apache/doris/backup/Repository.java
index 61df65ecc5..de5c475462 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/backup/Repository.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/backup/Repository.java
@@ -659,6 +659,10 @@ public class Repository implements Writable {
                     info.add(snapshotName);
                     info.add(Joiner.on("\n").join(tmp));
                     info.add("OK");
+                } else {
+                    info.add(snapshotName);
+                    info.add(FeConstants.null_string);
+                    info.add("ERROR: No info file found");
                 }
             }
         } else {


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


[doris] 16/38: [fix](jdbc) Added date type filtering pushed down to ClickHouse (#21709)

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 f7c90da4b9db6c45decd06cbf6f620bdb02c0265
Author: zy-kkk <zh...@gmail.com>
AuthorDate: Tue Jul 11 12:57:15 2023 +0800

    [fix](jdbc) Added date type filtering pushed down to ClickHouse (#21709)
    
    * [fix](jdbc) Added date type filtering pushed down to ClickHouse
    
    * fix
---
 .../java/org/apache/doris/planner/OdbcScanNode.java    | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/OdbcScanNode.java b/fe/fe-core/src/main/java/org/apache/doris/planner/OdbcScanNode.java
index 055269f68d..e22755d63e 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/OdbcScanNode.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/OdbcScanNode.java
@@ -100,6 +100,24 @@ public class OdbcScanNode extends ScanNode {
                 return filter;
             }
         }
+        if (tableType.equals(TOdbcTableType.CLICKHOUSE) && expr.contains(DateLiteral.class)
+                && (expr instanceof BinaryPredicate)) {
+            ArrayList<Expr> children = expr.getChildren();
+            if (children.get(1).isConstant() && (children.get(1).getType().isDate()) || children
+                    .get(1).getType().isDateV2()) {
+                String filter = children.get(0).toSql();
+                filter += ((BinaryPredicate) expr).getOp().toString();
+                filter += "date '" + children.get(1).getStringValue() + "'";
+                return filter;
+            }
+            if (children.get(1).isConstant() && (children.get(1).getType().isDatetime() || children
+                    .get(1).getType().isDatetimeV2())) {
+                String filter = children.get(0).toSql();
+                filter += ((BinaryPredicate) expr).getOp().toString();
+                filter += "timestamp '" + children.get(1).getStringValue() + "'";
+                return filter;
+            }
+        }
 
         return expr.toMySql();
     }


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


[doris] 30/38: [fix](segment-iterator) fix query result error caused by not handling error codes (#21901)

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 b269076f1bfdbc2ceca4c647b7bb544a7ae6c888
Author: Xin Liao <li...@126.com>
AuthorDate: Tue Jul 18 10:00:06 2023 +0800

    [fix](segment-iterator) fix query result error caused by not handling error codes (#21901)
---
 be/src/olap/rowset/segment_v2/segment_iterator.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/be/src/olap/rowset/segment_v2/segment_iterator.cpp b/be/src/olap/rowset/segment_v2/segment_iterator.cpp
index 968177404e..50aedd175b 100644
--- a/be/src/olap/rowset/segment_v2/segment_iterator.cpp
+++ b/be/src/olap/rowset/segment_v2/segment_iterator.cpp
@@ -1204,8 +1204,8 @@ Status SegmentIterator::next_batch(vectorized::Block* block) {
         // read 100 rows to estimate average row size
         nrows_read_limit = 100;
     }
-    _read_columns_by_index(nrows_read_limit, _current_batch_rows_read,
-                           _lazy_materialization_read || _opts.record_rowids);
+    RETURN_IF_ERROR(_read_columns_by_index(nrows_read_limit, _current_batch_rows_read,
+                                           _lazy_materialization_read || _opts.record_rowids));
 
     _opts.stats->blocks_load += 1;
     _opts.stats->raw_rows_read += _current_batch_rows_read;


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


[doris] 05/38: [fix](memtable) change memtable flush error code (#21542)

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 b66f77ad6cd3464a7b935e1e0e42b1ead4c9ec76
Author: HHoflittlefish777 <77...@users.noreply.github.com>
AuthorDate: Thu Jul 6 15:50:23 2023 +0800

    [fix](memtable) change memtable flush error code (#21542)
---
 be/src/olap/memtable_flush_executor.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/be/src/olap/memtable_flush_executor.cpp b/be/src/olap/memtable_flush_executor.cpp
index 48e0836a55..82ec2a7b97 100644
--- a/be/src/olap/memtable_flush_executor.cpp
+++ b/be/src/olap/memtable_flush_executor.cpp
@@ -94,7 +94,7 @@ void FlushToken::_flush_memtable(MemTable* memtable, int64_t submit_task_time) {
     if (!s) {
         LOG(WARNING) << "Flush memtable failed with res = " << s;
         // If s is not ok, ignore the code, just use other code is ok
-        _flush_status.store(ErrorCode::INTERNAL_ERROR);
+        _flush_status.store(s.code());
     }
 
     if (_flush_status.load() != OK) {


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


[doris] 28/38: [fix](merge-on-write) fix wrong result when query with prefix key predicate (#21770)

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 0aa24e027af020d15030edc714ef41d579e61fdb
Author: Xin Liao <li...@126.com>
AuthorDate: Thu Jul 13 19:56:00 2023 +0800

    [fix](merge-on-write) fix wrong result when query with prefix key predicate (#21770)
---
 be/src/olap/rowset/segment_v2/segment_iterator.cpp |   4 +-
 be/src/util/key_util.h                             |   7 +-
 .../correctness_p0/test_select_with_prefix.out     |  93 +++++++++++++
 .../correctness_p0/test_select_with_prefix.groovy  | 149 +++++++++++++++++++++
 4 files changed, 251 insertions(+), 2 deletions(-)

diff --git a/be/src/olap/rowset/segment_v2/segment_iterator.cpp b/be/src/olap/rowset/segment_v2/segment_iterator.cpp
index cb9dff43c1..968177404e 100644
--- a/be/src/olap/rowset/segment_v2/segment_iterator.cpp
+++ b/be/src/olap/rowset/segment_v2/segment_iterator.cpp
@@ -537,8 +537,10 @@ Status SegmentIterator::_lookup_ordinal_from_pk_index(const RowCursor& key, bool
     DCHECK(pk_index_reader != nullptr);
 
     std::string index_key;
+    // when is_include is false, we shoudle append KEY_NORMAL_MARKER to the
+    // encode key. Otherwise, we will get an incorrect upper bound.
     encode_key_with_padding<RowCursor, true, true>(
-            &index_key, key, _segment->_tablet_schema->num_key_columns(), is_include);
+            &index_key, key, _segment->_tablet_schema->num_key_columns(), is_include, true);
     if (index_key < _segment->min_key()) {
         *rowid = 0;
         return Status::OK();
diff --git a/be/src/util/key_util.h b/be/src/util/key_util.h
index 13cb5c1768..8a5b7613a8 100644
--- a/be/src/util/key_util.h
+++ b/be/src/util/key_util.h
@@ -58,15 +58,20 @@ constexpr uint8_t KEY_MAXIMAL_MARKER = 0xFF;
 // fill a marker and return. If padding_minimal is true, KEY_MINIMAL_MARKER will
 // be added, if padding_minimal is false, KEY_MAXIMAL_MARKER will be added.
 // If all num_keys are found in row, no marker will be added.
+// if padding_minimal is false and padding_normal_marker is true,
+// KEY_NORMAL_MARKER will be added.
 template <typename RowType, bool null_first = true, bool full_encode = false>
 void encode_key_with_padding(std::string* buf, const RowType& row, size_t num_keys,
-                             bool padding_minimal) {
+                             bool padding_minimal, bool padding_normal_marker = false) {
     for (auto cid = 0; cid < num_keys; cid++) {
         auto field = row.schema()->column(cid);
         if (field == nullptr) {
             if (padding_minimal) {
                 buf->push_back(KEY_MINIMAL_MARKER);
             } else {
+                if (padding_normal_marker) {
+                    buf->push_back(KEY_NORMAL_MARKER);
+                }
                 buf->push_back(KEY_MAXIMAL_MARKER);
             }
             break;
diff --git a/regression-test/data/correctness_p0/test_select_with_prefix.out b/regression-test/data/correctness_p0/test_select_with_prefix.out
new file mode 100644
index 0000000000..8b59f59f49
--- /dev/null
+++ b/regression-test/data/correctness_p0/test_select_with_prefix.out
@@ -0,0 +1,93 @@
+-- This file is automatically generated. You should know what you did if you want to edit this
+-- !sql --
+
+-- !sql --
+
+-- !sql --
+abcd	efgh	1	abcdad	2023-06-27T00:00	1
+abcd	efgh	2	abcdad	2023-06-27T00:00	1
+abcd	efghf	2	abcdad	2023-06-27T00:00	1
+
+-- !sql --
+abcd
+abcd
+abcd
+
+-- !sql --
+
+-- !sql --
+efgh
+efgh
+efghf
+
+-- !sql --
+	efgh	1	abcdad	2023-06-27T00:00	1
+	mefgh	1	abcdad	2023-06-27T00:00	1
+
+-- !sql --
+
+
+
+-- !sql --
+2
+
+-- !sql --
+
+-- !sql --
+
+-- !sql --
+	efgh	1	abcdad	2023-06-27T00:00	1
+abcd	efgh	1	abcdad	2023-06-27T00:00	1
+abcd	efgh	2	abcdad	2023-06-27T00:00	1
+
+-- !sql --
+
+abcd
+abcd
+
+-- !sql --
+
+-- !sql --
+
+-- !sql --
+abcd	efgh	1	abcdad	2023-06-27T00:00	1
+abcd	efgh	2	abcdad	2023-06-27T00:00	1
+abcd	efghf	2	abcdad	2023-06-27T00:00	1
+
+-- !sql --
+abcd
+abcd
+abcd
+
+-- !sql --
+
+-- !sql --
+efgh
+efgh
+efghf
+
+-- !sql --
+	efgh	1	abcdad	2023-06-27T00:00	1
+	mefgh	1	abcdad	2023-06-27T00:00	1
+
+-- !sql --
+
+
+
+-- !sql --
+2
+
+-- !sql --
+
+-- !sql --
+
+-- !sql --
+	efgh	1	abcdad	2023-06-27T00:00	1
+abcd	efgh	1	abcdad	2023-06-27T00:00	1
+abcd	efgh	2	abcdad	2023-06-27T00:00	1
+
+-- !sql --
+
+abcd
+abcd
+
diff --git a/regression-test/suites/correctness_p0/test_select_with_prefix.groovy b/regression-test/suites/correctness_p0/test_select_with_prefix.groovy
new file mode 100644
index 0000000000..c12e0da4c1
--- /dev/null
+++ b/regression-test/suites/correctness_p0/test_select_with_prefix.groovy
@@ -0,0 +1,149 @@
+
+// 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_select_with_prefix") {
+    def tableName = "test_select_with_perfix"
+    sql """ DROP TABLE IF EXISTS $tableName """
+    sql """
+        CREATE TABLE $tableName (
+       `c0` varchar(64) NULL,
+       `c1` varchar(64) NULL,
+       `c2` bigint(20) NOT NULL,
+       `c3` char(32) NULL,
+       `c4` datetime  NULL,
+       `c5` tinyint(4) NOT NULL
+     ) ENGINE=OLAP
+     UNIQUE KEY(`c0`, `c1`, `c2`, `c3`)
+     COMMENT 'OLAP'
+     DISTRIBUTED BY HASH(`c0`) BUCKETS 1
+     PROPERTIES (
+     "replication_allocation" = "tag.location.default: 1",
+     "enable_unique_key_merge_on_write" = "true"
+     );
+    """
+
+    sql """
+         INSERT INTO $tableName (`c0`, `c1`, `c2`, `c3`, `c4`, `c5`) VALUES
+             ('', 'efgh', 1, 'abcdad', '2023-06-27 00:00:00', 1),
+             ('', 'mefgh', 1, 'abcdad', '2023-06-27 00:00:00', 1),
+             ('abcd', 'efgh', 1, 'abcdad', '2023-06-27 00:00:00', 1),
+             ('abcd', 'efgh', 2, 'abcdad', '2023-06-27 00:00:00', 1),
+             ('abcd', 'efghf', 2, 'abcdad', '2023-06-27 00:00:00', 1),
+             ('abcde', 'ab', 2, '2efraeef', '2023-06-27 00:00:00', 1),
+             ('abcdf', 'ab', 2, '2efraeef', '2023-06-27 00:00:00', 1),
+             ('abcdf', 'dab', 2, '2efraeef', '2023-06-27 00:00:00', 1),
+             ('abce', 'dab', 2, '2efraeef', '2023-06-27 00:00:00', 1),
+             ('abce', 'ldab', 2, '2efraeef', '2023-06-27 00:00:00', 1),
+             ('abd', 'ldab', 2, '2efraeef', '2023-06-27 00:00:00', 1),
+             ('def', 'hh', 2, 'afad', '2023-06-27 00:00:00', 1)
+    """
+
+    sql "sync"
+
+    qt_sql "select * from $tableName where c0='abc'"
+
+    qt_sql "select c0 from $tableName where c0='abc'"
+
+    qt_sql "select * from $tableName where c0='abcd'"
+
+    qt_sql "select c0 from $tableName where c0='abcd'"
+
+    qt_sql "select c1 from $tableName where c0='abc'"
+
+    qt_sql "select c1 from $tableName where c0='abcd'"
+
+    qt_sql "select * from $tableName where c0=''"
+
+    qt_sql "select c0 from $tableName where c0=''"
+    
+    qt_sql "select count(*) from $tableName where c0=''"
+
+    qt_sql "select * from $tableName where c1='efg'"
+
+    qt_sql "select c0 from $tableName where c1='efg'"
+
+    qt_sql "select * from $tableName where c1='efgh'"
+
+    qt_sql "select c0 from $tableName where c1='efgh'"
+
+    sql """ DROP TABLE IF EXISTS $tableName """
+    sql """
+        CREATE TABLE $tableName (
+       `c0` varchar(64) NULL,
+       `c1` varchar(64) NULL,
+       `c2` bigint(20) NOT NULL,
+       `c3` char(32) NULL,
+       `c4` datetime  NULL,
+       `c5` tinyint(4) NOT NULL
+     ) ENGINE=OLAP
+     UNIQUE KEY(`c0`, `c1`, `c2`, `c3`)
+     COMMENT 'OLAP'
+     DISTRIBUTED BY HASH(`c0`) BUCKETS 1
+     PROPERTIES (
+     "replication_allocation" = "tag.location.default: 1",
+     "enable_unique_key_merge_on_write" = "false"
+     );
+    """
+
+    sql """
+         INSERT INTO $tableName (`c0`, `c1`, `c2`, `c3`, `c4`, `c5`) VALUES
+             ('', 'efgh', 1, 'abcdad', '2023-06-27 00:00:00', 1),
+             ('', 'mefgh', 1, 'abcdad', '2023-06-27 00:00:00', 1),
+             ('abcd', 'efgh', 1, 'abcdad', '2023-06-27 00:00:00', 1),
+             ('abcd', 'efgh', 2, 'abcdad', '2023-06-27 00:00:00', 1),
+             ('abcd', 'efghf', 2, 'abcdad', '2023-06-27 00:00:00', 1),
+             ('abcde', 'ab', 2, '2efraeef', '2023-06-27 00:00:00', 1),
+             ('abcdf', 'ab', 2, '2efraeef', '2023-06-27 00:00:00', 1),
+             ('abcdf', 'dab', 2, '2efraeef', '2023-06-27 00:00:00', 1),
+             ('abce', 'dab', 2, '2efraeef', '2023-06-27 00:00:00', 1),
+             ('abce', 'ldab', 2, '2efraeef', '2023-06-27 00:00:00', 1),
+             ('abd', 'ldab', 2, '2efraeef', '2023-06-27 00:00:00', 1),
+             ('def', 'hh', 2, 'afad', '2023-06-27 00:00:00', 1)
+    """
+
+    sql "sync"
+
+    qt_sql "select * from $tableName where c0='abc'"
+
+    qt_sql "select c0 from $tableName where c0='abc'"
+
+    qt_sql "select * from $tableName where c0='abcd'"
+
+    qt_sql "select c0 from $tableName where c0='abcd'"
+
+    qt_sql "select c1 from $tableName where c0='abc'"
+
+    qt_sql "select c1 from $tableName where c0='abcd'"
+
+    qt_sql "select * from $tableName where c0=''"
+
+    qt_sql "select c0 from $tableName where c0=''"
+    
+    qt_sql "select count(*) from $tableName where c0=''"
+
+    qt_sql "select * from $tableName where c1='efg'"
+
+    qt_sql "select c0 from $tableName where c1='efg'"
+
+    qt_sql "select * from $tableName where c1='efgh'"
+
+    qt_sql "select c0 from $tableName where c1='efgh'"
+
+    sql """ DROP TABLE IF EXISTS $tableName """
+}
+


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


[doris] 34/38: [fix](in) fix wrong DCHECK of in expr for not nullable column (#21934)

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 1c8ff29cf0b1532d34d636ff5e84a963aa1bb08f
Author: TengJianPing <18...@users.noreply.github.com>
AuthorDate: Tue Jul 18 19:31:01 2023 +0800

    [fix](in) fix wrong DCHECK of in expr for not nullable column (#21934)
    
    DCHECK(!in_state->null_in_set); in FunctionIn::execute_impl when left column is not nullable is not necessary, remove it;
    function convert_type_to_primitive in be/src/runtime/primitive_type.cpp forget to handle float type, fix it;
    when left column is not nullable, if values in expr list have null value, nullable flags should also be set as when left column is nullable.
---
 be/src/runtime/primitive_type.cpp                  |  54 ++++----
 be/src/vec/functions/in.h                          |   6 +-
 .../data/query_p0/sql_functions/test_in_expr.out   | 144 ++++++++++++++++++++-
 .../query_p0/sql_functions/test_in_expr.groovy     |  34 ++++-
 4 files changed, 201 insertions(+), 37 deletions(-)

diff --git a/be/src/runtime/primitive_type.cpp b/be/src/runtime/primitive_type.cpp
index 779676a45d..9e4fd901ea 100644
--- a/be/src/runtime/primitive_type.cpp
+++ b/be/src/runtime/primitive_type.cpp
@@ -29,36 +29,10 @@ PrimitiveType convert_type_to_primitive(FunctionContext::Type type) {
     switch (type) {
     case FunctionContext::Type::INVALID_TYPE:
         return PrimitiveType::INVALID_TYPE;
-    case FunctionContext::Type::TYPE_DOUBLE:
-        return PrimitiveType::TYPE_DOUBLE;
     case FunctionContext::Type::TYPE_NULL:
         return PrimitiveType::TYPE_NULL;
-    case FunctionContext::Type::TYPE_CHAR:
-        return PrimitiveType::TYPE_CHAR;
-    case FunctionContext::Type::TYPE_VARCHAR:
-        return PrimitiveType::TYPE_VARCHAR;
-    case FunctionContext::Type::TYPE_STRING:
-        return PrimitiveType::TYPE_STRING;
-    case FunctionContext::Type::TYPE_DATETIME:
-        return PrimitiveType::TYPE_DATETIME;
-    case FunctionContext::Type::TYPE_DECIMALV2:
-        return PrimitiveType::TYPE_DECIMALV2;
-    case FunctionContext::Type::TYPE_DECIMAL32:
-        return PrimitiveType::TYPE_DECIMAL32;
-    case FunctionContext::Type::TYPE_DECIMAL64:
-        return PrimitiveType::TYPE_DECIMAL64;
-    case FunctionContext::Type::TYPE_DECIMAL128I:
-        return PrimitiveType::TYPE_DECIMAL128I;
     case FunctionContext::Type::TYPE_BOOLEAN:
         return PrimitiveType::TYPE_BOOLEAN;
-    case FunctionContext::Type::TYPE_ARRAY:
-        return PrimitiveType::TYPE_ARRAY;
-    case FunctionContext::Type::TYPE_OBJECT:
-        return PrimitiveType::TYPE_OBJECT;
-    case FunctionContext::Type::TYPE_HLL:
-        return PrimitiveType::TYPE_HLL;
-    case FunctionContext::Type::TYPE_QUANTILE_STATE:
-        return PrimitiveType::TYPE_QUANTILE_STATE;
     case FunctionContext::Type::TYPE_TINYINT:
         return PrimitiveType::TYPE_TINYINT;
     case FunctionContext::Type::TYPE_SMALLINT:
@@ -69,14 +43,42 @@ PrimitiveType convert_type_to_primitive(FunctionContext::Type type) {
         return PrimitiveType::TYPE_BIGINT;
     case FunctionContext::Type::TYPE_LARGEINT:
         return PrimitiveType::TYPE_LARGEINT;
+    case FunctionContext::Type::TYPE_FLOAT:
+        return PrimitiveType::TYPE_FLOAT;
+    case FunctionContext::Type::TYPE_DOUBLE:
+        return PrimitiveType::TYPE_DOUBLE;
     case FunctionContext::Type::TYPE_DATE:
         return PrimitiveType::TYPE_DATE;
+    case FunctionContext::Type::TYPE_DATETIME:
+        return PrimitiveType::TYPE_DATETIME;
+    case FunctionContext::Type::TYPE_CHAR:
+        return PrimitiveType::TYPE_CHAR;
+    case FunctionContext::Type::TYPE_VARCHAR:
+        return PrimitiveType::TYPE_VARCHAR;
+    case FunctionContext::Type::TYPE_HLL:
+        return PrimitiveType::TYPE_HLL;
+    case FunctionContext::Type::TYPE_STRING:
+        return PrimitiveType::TYPE_STRING;
+    case FunctionContext::Type::TYPE_DECIMALV2:
+        return PrimitiveType::TYPE_DECIMALV2;
+    case FunctionContext::Type::TYPE_OBJECT:
+        return PrimitiveType::TYPE_OBJECT;
+    case FunctionContext::Type::TYPE_ARRAY:
+        return PrimitiveType::TYPE_ARRAY;
+    case FunctionContext::Type::TYPE_QUANTILE_STATE:
+        return PrimitiveType::TYPE_QUANTILE_STATE;
     case FunctionContext::Type::TYPE_DATEV2:
         return PrimitiveType::TYPE_DATEV2;
     case FunctionContext::Type::TYPE_DATETIMEV2:
         return PrimitiveType::TYPE_DATETIMEV2;
     case FunctionContext::Type::TYPE_TIMEV2:
         return PrimitiveType::TYPE_TIMEV2;
+    case FunctionContext::Type::TYPE_DECIMAL32:
+        return PrimitiveType::TYPE_DECIMAL32;
+    case FunctionContext::Type::TYPE_DECIMAL64:
+        return PrimitiveType::TYPE_DECIMAL64;
+    case FunctionContext::Type::TYPE_DECIMAL128I:
+        return PrimitiveType::TYPE_DECIMAL128I;
     case FunctionContext::Type::TYPE_JSONB:
         return PrimitiveType::TYPE_JSONB;
     default:
diff --git a/be/src/vec/functions/in.h b/be/src/vec/functions/in.h
index 626060e399..756eac91b8 100644
--- a/be/src/vec/functions/in.h
+++ b/be/src/vec/functions/in.h
@@ -156,7 +156,6 @@ public:
                 }
 
             } else { // non-nullable
-                DCHECK(!in_state->null_in_set);
 
                 auto search_hash_set = [&](auto* col_ptr) {
                     for (size_t i = 0; i < input_rows_count; ++i) {
@@ -177,6 +176,11 @@ public:
                 } else {
                     search_hash_set(materialized_column.get());
                 }
+                if (in_state->null_in_set) {
+                    for (size_t i = 0; i < input_rows_count; ++i) {
+                        vec_null_map_to[i] = negative == vec_res[i];
+                    }
+                }
             }
         } else {
             std::vector<ColumnPtr> set_columns;
diff --git a/regression-test/data/query_p0/sql_functions/test_in_expr.out b/regression-test/data/query_p0/sql_functions/test_in_expr.out
index c7f58848a5..654440cc2d 100644
--- a/regression-test/data/query_p0/sql_functions/test_in_expr.out
+++ b/regression-test/data/query_p0/sql_functions/test_in_expr.out
@@ -8,12 +8,60 @@
 -- !select --
 
 -- !select --
-103	4	d
-
--- !select --
-103	4	d
-
--- !select --
+103	4	d	1.4
+
+-- !select --
+103	4	d	1.4
+
+-- !select --
+
+-- !select_float_in --
+1.1	\N
+1.2	\N
+1.3	\N
+1.4	\N
+1.5	\N
+\N	\N
+
+-- !select_float_in2 --
+1.1	\N
+1.2	\N
+1.3	\N
+1.4	\N
+1.5	\N
+\N	\N
+
+-- !select_float_in3 --
+1.1	\N
+1.2	\N
+1.3	\N
+1.4	\N
+1.5	\N
+\N	\N
+
+-- !select_float_in4 --
+1.1	\N
+1.2	\N
+1.3	\N
+1.4	\N
+1.5	\N
+\N	\N
+
+-- !select_float_in5 --
+1.1	\N
+1.2	\N
+1.3	\N
+1.4	\N
+1.5	\N
+\N	\N
+
+-- !select_float_in6 --
+1.1	\N
+1.2	\N
+1.3	\N
+1.4	\N
+1.5	\N
+\N	\N
 
 -- !select --
 c
@@ -53,6 +101,90 @@ a
 b
 d
 
+-- !select_not_null_in_null --
+100	true
+101	\N
+102	\N
+103	\N
+
+-- !select_not_null_in_null2 --
+100	\N
+101	\N
+102	\N
+103	\N
+
+-- !select_not_null_in_null3 --
+a	true
+b	\N
+c	\N
+d	\N
+
+-- !select_not_null_in_null4 --
+a	\N
+b	\N
+c	\N
+d	\N
+
+-- !select_not_null_not_in_null --
+100	false
+101	\N
+102	\N
+103	\N
+
+-- !select_not_null_not_in_null2 --
+100	\N
+101	\N
+102	\N
+103	\N
+
+-- !select_not_null_not_in_null3 --
+a	false
+b	\N
+c	\N
+d	\N
+
+-- !select_not_null_not_in_null4 --
+a	\N
+b	\N
+c	\N
+d	\N
+
+-- !select_not_null_float_in --
+1.1	\N
+1.2	\N
+1.3	\N
+1.4	\N
+
+-- !select_not_null_float_in2 --
+1.1	\N
+1.2	\N
+1.3	\N
+1.4	\N
+
+-- !select_not_null_float_in3 --
+1.1	\N
+1.2	\N
+1.3	\N
+1.4	\N
+
+-- !select_not_null_float_in4 --
+1.1	\N
+1.2	\N
+1.3	\N
+1.4	\N
+
+-- !select_not_null_float_in5 --
+1.1	\N
+1.2	\N
+1.3	\N
+1.4	\N
+
+-- !select_not_null_float_in6 --
+1.1	\N
+1.2	\N
+1.3	\N
+1.4	\N
+
 -- !select --
 2
 3
diff --git a/regression-test/suites/query_p0/sql_functions/test_in_expr.groovy b/regression-test/suites/query_p0/sql_functions/test_in_expr.groovy
index a2424e4d82..495c359fe2 100644
--- a/regression-test/suites/query_p0/sql_functions/test_in_expr.groovy
+++ b/regression-test/suites/query_p0/sql_functions/test_in_expr.groovy
@@ -24,7 +24,8 @@ suite("test_in_expr", "query") {
             CREATE TABLE IF NOT EXISTS ${nullTableName} (
               `cid` int(11) NULL,
               `number` int(11) NULL,
-              `addr` varchar(256) NULL
+              `addr` varchar(256) NULL,
+              `fnum` float NULL
             ) ENGINE=OLAP
             DUPLICATE KEY(`cid`)
             COMMENT 'OLAP'
@@ -35,7 +36,7 @@ suite("test_in_expr", "query") {
             "storage_format" = "V2"
             )
         """
-    sql """ insert into ${nullTableName} values(100,1,'a'),(101,2,'b'),(102,3,'c'),(103,4,'d'),(104,null,'e'),(105,6, null) """
+    sql """ insert into ${nullTableName} values(100,1,'a', 1.1),(101,2,'b',1.2),(102,3,'c',1.3),(103,4,'d',1.4),(104,null,'e',1.5),(105,6, null,null) """
 
 
     sql """DROP TABLE IF EXISTS ${notNullTableName}"""
@@ -43,7 +44,8 @@ suite("test_in_expr", "query") {
             CREATE TABLE IF NOT EXISTS ${notNullTableName} (
               `cid` int(11) not NULL,
               `number` int(11) not NULL,
-              `addr` varchar(256) not NULL
+              `addr` varchar(256) not NULL,
+              `fnum` float not NULL
             ) ENGINE=OLAP
             DUPLICATE KEY(`cid`)
             COMMENT 'OLAP'
@@ -55,7 +57,7 @@ suite("test_in_expr", "query") {
             )
         """
 
-    sql """ insert into ${notNullTableName} values(100,1,'a'),(101,2,'b'),(102,3,'c'),(103,4,'d') """
+    sql """ insert into ${notNullTableName} values(100,1,'a', 1.1),(101,2,'b', 1.2),(102,3,'c',1.3),(103,4,'d',1.4) """
 
     sql """ set enable_vectorized_engine = true """
 
@@ -75,6 +77,13 @@ suite("test_in_expr", "query") {
 
     qt_select "select * from ${nullTableName} where not(addr in ('d', null))"
 
+    qt_select_float_in """ select fnum,  fnum in (1.1, null) from ${nullTableName} order by cid"""
+    qt_select_float_in2 """ select fnum,  not (fnum in (1.1, null)) from ${nullTableName} order by cid"""
+    qt_select_float_in3 """ select fnum,  fnum not in (1.1, null) from ${nullTableName} order by cid"""
+    qt_select_float_in4 """ select fnum,  fnum in (null) from ${nullTableName} order by cid"""
+    qt_select_float_in5 """ select fnum,  not(fnum in (null)) from ${nullTableName} order by cid"""
+    qt_select_float_in6 """ select fnum,  fnum not in (null) from ${nullTableName} order by cid"""
+
     // 1.1.3 non-string
     qt_select "select t1.addr from ${nullTableName} t1 left join ${nullTableName} t2 on t1.cid=t2.cid where t2.number in (3)"
 
@@ -112,6 +121,23 @@ suite("test_in_expr", "query") {
     // 2.1.3 non-string
     qt_select "select t1.addr from ${notNullTableName} t1 left join ${notNullTableName} t2 on t1.cid=t2.cid where t2.number not in (3) order by t1.addr "
 
+    qt_select_not_null_in_null """ select cid, cid in (100, null) from ${notNullTableName} order by cid"""
+    qt_select_not_null_in_null2 """ select cid, cid in (null) from ${notNullTableName} order by cid"""
+    qt_select_not_null_in_null3 """ select addr, addr in ('a', null) from ${notNullTableName} order by addr"""
+    qt_select_not_null_in_null4 """ select addr, addr in (null) from ${notNullTableName} order by addr"""
+
+    qt_select_not_null_not_in_null """ select cid, cid not in (100, null) from ${notNullTableName} order by cid"""
+    qt_select_not_null_not_in_null2 """ select cid, cid not in (null) from ${notNullTableName} order by cid"""
+    qt_select_not_null_not_in_null3 """ select addr, addr not in ('a', null) from ${notNullTableName} order by addr"""
+    qt_select_not_null_not_in_null4 """ select addr, addr not in (null) from ${notNullTableName} order by addr"""
+
+    qt_select_not_null_float_in """ select fnum,  fnum in (1.1, null) from ${notNullTableName} order by cid"""
+    qt_select_not_null_float_in2 """ select fnum,  not (fnum in (1.1, null)) from ${notNullTableName} order by cid"""
+    qt_select_not_null_float_in3 """ select fnum,  fnum not in (1.1, null) from ${notNullTableName} order by cid"""
+    qt_select_not_null_float_in4 """ select fnum,  fnum in (null) from ${notNullTableName} order by cid"""
+    qt_select_not_null_float_in5 """ select fnum,  not(fnum in (null)) from ${notNullTableName} order by cid"""
+    qt_select_not_null_float_in6 """ select fnum,  fnum not in (null) from ${notNullTableName} order by cid"""
+
     sql """DROP TABLE IF EXISTS ${nullTableName}"""
     sql """DROP TABLE IF EXISTS ${notNullTableName}"""
 


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


[doris] 11/38: [FIX](array)Fix update hash func array (#21630)

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 f5aac9c5466fc0716e052cf4a6eb7857b0a96dee
Author: amory <wa...@selectdb.com>
AuthorDate: Sun Jul 9 22:03:58 2023 +0800

    [FIX](array)Fix update hash func array (#21630)
---
 be/src/vec/columns/column.h             | 16 ++++++---
 be/src/vec/columns/column_array.cpp     | 62 +++++++++++++++++++++++++++++++--
 be/src/vec/columns/column_array.h       | 14 +++++++-
 be/src/vec/columns/column_const.h       | 12 +++++++
 be/src/vec/columns/column_decimal.cpp   | 32 ++++++++++-------
 be/src/vec/columns/column_decimal.h     |  2 ++
 be/src/vec/columns/column_nullable.cpp  | 18 ++++++++++
 be/src/vec/columns/column_nullable.h    |  2 ++
 be/src/vec/columns/column_string.h      | 12 +++++++
 be/src/vec/columns/column_vector.h      | 19 ++++++++++
 be/src/vec/sink/vdata_stream_sender.cpp |  3 ++
 11 files changed, 172 insertions(+), 20 deletions(-)

diff --git a/be/src/vec/columns/column.h b/be/src/vec/columns/column.h
index 0a2c66183e..89dd4fbef4 100644
--- a/be/src/vec/columns/column.h
+++ b/be/src/vec/columns/column.h
@@ -339,7 +339,7 @@ public:
     /// On subsequent calls of this method for sequence of column values of arbitrary types,
     ///  passed bytes to hash must identify sequence of values unambiguously.
     virtual void update_hash_with_value(size_t n, SipHash& hash) const {
-        LOG(FATAL) << "update_hash_with_value siphash not supported";
+        LOG(FATAL) << get_name() << "update_hash_with_value siphash not supported";
     }
 
     /// Update state of hash function with value of n elements to avoid the virtual function call
@@ -348,7 +348,7 @@ public:
     /// do xxHash here, faster than other hash method
     virtual void update_hashes_with_value(std::vector<SipHash>& hashes,
                                           const uint8_t* __restrict null_data = nullptr) const {
-        LOG(FATAL) << "update_hashes_with_value siphash not supported";
+        LOG(FATAL) << get_name() << "update_hashes_with_value siphash not supported";
     };
 
     /// Update state of hash function with value of n elements to avoid the virtual function call
@@ -357,17 +357,25 @@ public:
     /// do xxHash here, faster than other sip hash
     virtual void update_hashes_with_value(uint64_t* __restrict hashes,
                                           const uint8_t* __restrict null_data = nullptr) const {
-        LOG(FATAL) << "update_hashes_with_value xxhash not supported";
+        LOG(FATAL) << get_name() << "update_hashes_with_value xxhash not supported";
     };
 
+    virtual void update_xxHash_with_value(size_t n, uint64_t& hash) const {
+        LOG(FATAL) << get_name() << " update_hash_with_value xxhash not supported";
+    }
+
     /// Update state of crc32 hash function with value of n elements to avoid the virtual function call
     /// null_data to mark whether need to do hash compute, null_data == nullptr
     /// means all element need to do hash function, else only *null_data != 0 need to do hash func
     virtual void update_crcs_with_value(std::vector<uint64_t>& hash, PrimitiveType type,
                                         const uint8_t* __restrict null_data = nullptr) const {
-        LOG(FATAL) << "update_crcs_with_value not supported";
+        LOG(FATAL) << get_name() << "update_crcs_with_value not supported";
     };
 
+    virtual void update_crc_with_value(size_t n, uint64_t& hash) const {
+        LOG(FATAL) << get_name() << " update_crc_with_value not supported";
+    }
+
     /** Removes elements that don't match the filter.
       * Is used in WHERE and HAVING operations.
       * If result_size_hint > 0, then makes advance reserve(result_size_hint) for the result column;
diff --git a/be/src/vec/columns/column_array.cpp b/be/src/vec/columns/column_array.cpp
index 4ae7ada9f7..999991fde5 100644
--- a/be/src/vec/columns/column_array.cpp
+++ b/be/src/vec/columns/column_array.cpp
@@ -223,11 +223,67 @@ const char* ColumnArray::deserialize_and_insert_from_arena(const char* pos) {
     return pos;
 }
 
-void ColumnArray::update_hash_with_value(size_t n, SipHash& hash) const {
-    size_t array_size = size_at(n);
+void ColumnArray::update_hashes_with_value(std::vector<SipHash>& hashes,
+                                           const uint8_t* __restrict null_data) const {
+    SIP_HASHES_FUNCTION_COLUMN_IMPL();
+}
+
+// for every array row calculate xxHash
+void ColumnArray::update_xxHash_with_value(size_t n, uint64_t& hash) const {
+    size_t elem_size = size_at(n);
+    size_t offset = offset_at(n);
+    hash = HashUtil::xxHash64WithSeed(reinterpret_cast<const char*>(&elem_size), sizeof(elem_size),
+                                      hash);
+    for (auto i = 0; i < elem_size; ++i) {
+        get_data().update_xxHash_with_value(offset + i, hash);
+    }
+}
+
+// for every array row calculate crcHash
+void ColumnArray::update_crc_with_value(size_t n, uint64_t& crc) const {
+    size_t elem_size = size_at(n);
     size_t offset = offset_at(n);
 
-    for (size_t i = 0; i < array_size; ++i) get_data().update_hash_with_value(offset + i, hash);
+    crc = HashUtil::zlib_crc_hash(reinterpret_cast<const char*>(&elem_size), sizeof(elem_size),
+                                  crc);
+    for (auto i = 0; i < elem_size; ++i) {
+        get_data().update_crc_with_value(offset + i, crc);
+    }
+}
+
+void ColumnArray::update_hashes_with_value(uint64_t* __restrict hashes,
+                                           const uint8_t* __restrict null_data) const {
+    auto s = size();
+    if (null_data) {
+        for (size_t i = 0; i < s; ++i) {
+            if (null_data[i] == 0) {
+                update_xxHash_with_value(i, hashes[i]);
+            }
+        }
+    } else {
+        for (size_t i = 0; i < s; ++i) {
+            update_xxHash_with_value(i, hashes[i]);
+        }
+    }
+}
+
+void ColumnArray::update_crcs_with_value(std::vector<uint64_t>& hash, PrimitiveType type,
+                                         const uint8_t* __restrict null_data) const {
+    auto s = hash.size();
+    DCHECK(s == size());
+
+    if (null_data) {
+        for (size_t i = 0; i < s; ++i) {
+            // every row
+            if (null_data[i] == 0) {
+                update_crc_with_value(i, hash[i]);
+            }
+        }
+    } else {
+        for (size_t i = 0; i < s; ++i) {
+            update_crc_with_value(i, hash[i]);
+        }
+    }
 }
 
 void ColumnArray::insert(const Field& x) {
diff --git a/be/src/vec/columns/column_array.h b/be/src/vec/columns/column_array.h
index 824cca8b23..7239de3347 100644
--- a/be/src/vec/columns/column_array.h
+++ b/be/src/vec/columns/column_array.h
@@ -97,7 +97,17 @@ public:
     void insert_data(const char* pos, size_t length) override;
     StringRef serialize_value_into_arena(size_t n, Arena& arena, char const*& begin) const override;
     const char* deserialize_and_insert_from_arena(const char* pos) override;
-    void update_hash_with_value(size_t n, SipHash& hash) const override;
+    void update_xxHash_with_value(size_t n, uint64_t& hash) const override;
+    void update_crc_with_value(size_t n, uint64_t& crc) const override;
+
+    void update_hashes_with_value(std::vector<SipHash>& hashes,
+                                  const uint8_t* __restrict null_data) const override;
+
+    void update_hashes_with_value(uint64_t* __restrict hashes,
+                                  const uint8_t* __restrict null_data = nullptr) const override;
+
+    void update_crcs_with_value(std::vector<uint64_t>& hash, PrimitiveType type,
+                                const uint8_t* __restrict null_data = nullptr) const override;
     void insert_range_from(const IColumn& src, size_t start, size_t length) override;
     void insert(const Field& x) override;
     void insert_from(const IColumn& src_, size_t n) override;
@@ -179,6 +189,8 @@ public:
     Status filter_by_selector(const uint16_t* sel, size_t sel_size, IColumn* col_ptr) override;
 
 private:
+    // [[2,1,5,9,1], [1,2,4]] --> data column [2,1,5,9,1,1,2,4], offset[-1] = 0, offset[0] = 5, offset[1] = 8
+    // [[[2,1,5],[9,1]], [[1,2]]] --> data column [3 column array], offset[-1] = 0, offset[0] = 2, offset[1] = 3
     WrappedPtr data;
     WrappedPtr offsets;
 
diff --git a/be/src/vec/columns/column_const.h b/be/src/vec/columns/column_const.h
index 9637a0943f..13640a0a9a 100644
--- a/be/src/vec/columns/column_const.h
+++ b/be/src/vec/columns/column_const.h
@@ -135,6 +135,18 @@ public:
 
     void update_hashes_with_value(uint64_t* __restrict hashes,
                                   const uint8_t* __restrict null_data) const override;
+    void update_xxHash_with_value(size_t n, uint64_t& hash) const override {
+        auto real_data = data->get_data_at(0);
+        if (real_data.data == nullptr) {
+            hash = HashUtil::xxHash64NullWithSeed(hash);
+        } else {
+            hash = HashUtil::xxHash64WithSeed(real_data.data, real_data.size, hash);
+        }
+    }
+
+    void update_crc_with_value(size_t n, uint64_t& crc) const override {
+        get_data_column_ptr()->update_crc_with_value(n, crc);
+    }
 
     ColumnPtr filter(const Filter& filt, ssize_t result_size_hint) const override;
     ColumnPtr replicate(const Offsets& offsets) const override;
diff --git a/be/src/vec/columns/column_decimal.cpp b/be/src/vec/columns/column_decimal.cpp
index 13902b54a7..78e7d055cb 100644
--- a/be/src/vec/columns/column_decimal.cpp
+++ b/be/src/vec/columns/column_decimal.cpp
@@ -127,36 +127,44 @@ void ColumnDecimal<T>::update_hashes_with_value(std::vector<SipHash>& hashes,
     SIP_HASHES_FUNCTION_COLUMN_IMPL();
 }
 
+template <typename T>
+void ColumnDecimal<T>::update_crc_with_value(size_t n, uint64_t& crc) const {
+    if constexpr (!IsDecimalV2<T>) {
+        crc = HashUtil::zlib_crc_hash(&data[n], sizeof(T), crc);
+    } else {
+        const DecimalV2Value& dec_val = (const DecimalV2Value&)data[n];
+        int64_t int_val = dec_val.int_value();
+        int32_t frac_val = dec_val.frac_value();
+        crc = HashUtil::zlib_crc_hash(&int_val, sizeof(int_val), crc);
+        crc = HashUtil::zlib_crc_hash(&frac_val, sizeof(frac_val), crc);
+    };
+}
+
 template <typename T>
 void ColumnDecimal<T>::update_crcs_with_value(std::vector<uint64_t>& hashes, PrimitiveType type,
                                               const uint8_t* __restrict null_data) const {
     auto s = hashes.size();
     DCHECK(s == size());
-
     if constexpr (!IsDecimalV2<T>) {
         DO_CRC_HASHES_FUNCTION_COLUMN_IMPL()
     } else {
-        DCHECK(type == TYPE_DECIMALV2);
-        auto decimalv2_do_crc = [&](size_t i) {
-            const DecimalV2Value& dec_val = (const DecimalV2Value&)data[i];
-            int64_t int_val = dec_val.int_value();
-            int32_t frac_val = dec_val.frac_value();
-            hashes[i] = HashUtil::zlib_crc_hash(&int_val, sizeof(int_val), hashes[i]);
-            hashes[i] = HashUtil::zlib_crc_hash(&frac_val, sizeof(frac_val), hashes[i]);
-        };
-
         if (null_data == nullptr) {
             for (size_t i = 0; i < s; i++) {
-                decimalv2_do_crc(i);
+                update_crc_with_value(i, hashes[i]);
             }
         } else {
             for (size_t i = 0; i < s; i++) {
-                if (null_data[i] == 0) decimalv2_do_crc(i);
+                if (null_data[i] == 0) update_crc_with_value(i, hashes[i]);
             }
         }
     }
 }
 
+template <typename T>
+void ColumnDecimal<T>::update_xxHash_with_value(size_t n, uint64_t& hash) const {
+    hash = HashUtil::xxHash64WithSeed(reinterpret_cast<const char*>(&data[n]), sizeof(T), hash);
+}
+
 template <typename T>
 void ColumnDecimal<T>::update_hashes_with_value(uint64_t* __restrict hashes,
                                                 const uint8_t* __restrict null_data) const {
diff --git a/be/src/vec/columns/column_decimal.h b/be/src/vec/columns/column_decimal.h
index a3960067cb..8968ff6017 100644
--- a/be/src/vec/columns/column_decimal.h
+++ b/be/src/vec/columns/column_decimal.h
@@ -159,6 +159,8 @@ public:
                                   const uint8_t* __restrict null_data) const override;
     void update_crcs_with_value(std::vector<uint64_t>& hashes, PrimitiveType type,
                                 const uint8_t* __restrict null_data) const override;
+    void update_xxHash_with_value(size_t n, uint64_t& hash) const override;
+    void update_crc_with_value(size_t n, uint64_t& crc) const override;
 
     int compare_at(size_t n, size_t m, const IColumn& rhs_, int nan_direction_hint) const override;
     void get_permutation(bool reverse, size_t limit, int nan_direction_hint,
diff --git a/be/src/vec/columns/column_nullable.cpp b/be/src/vec/columns/column_nullable.cpp
index 5b087550cc..0e90251343 100644
--- a/be/src/vec/columns/column_nullable.cpp
+++ b/be/src/vec/columns/column_nullable.cpp
@@ -114,6 +114,24 @@ void ColumnNullable::update_hashes_with_value(uint64_t* __restrict hashes,
     }
 }
 
+void ColumnNullable::update_xxHash_with_value(size_t n, uint64_t& hash) const {
+    auto* __restrict real_null_data = assert_cast<const ColumnUInt8&>(*null_map).get_data().data();
+    if (real_null_data[n] != 0) {
+        hash = HashUtil::xxHash64NullWithSeed(hash);
+    } else {
+        nested_column->update_xxHash_with_value(n, hash);
+    }
+}
+
+void ColumnNullable::update_crc_with_value(size_t n, uint64_t& crc) const {
+    auto* __restrict real_null_data = assert_cast<const ColumnUInt8&>(*null_map).get_data().data();
+    if (real_null_data[n] != 0) {
+        crc = HashUtil::zlib_crc_hash_null(crc);
+    } else {
+        nested_column->update_xxHash_with_value(n, crc);
+    }
+}
+
 MutableColumnPtr ColumnNullable::clone_resized(size_t new_size) const {
     MutableColumnPtr new_nested_col = get_nested_column().clone_resized(new_size);
     auto new_null_map = ColumnUInt8::create();
diff --git a/be/src/vec/columns/column_nullable.h b/be/src/vec/columns/column_nullable.h
index fe34724954..9f29965a32 100644
--- a/be/src/vec/columns/column_nullable.h
+++ b/be/src/vec/columns/column_nullable.h
@@ -186,6 +186,8 @@ public:
                                 const uint8_t* __restrict null_data) const override;
     void update_hashes_with_value(uint64_t* __restrict hashes,
                                   const uint8_t* __restrict null_data) const override;
+    void update_xxHash_with_value(size_t n, uint64_t& hash) const override;
+    void update_crc_with_value(size_t n, uint64_t& crc) const override;
     void get_extremes(Field& min, Field& max) const override;
 
     MutableColumns scatter(ColumnIndex num_columns, const Selector& selector) const override {
diff --git a/be/src/vec/columns/column_string.h b/be/src/vec/columns/column_string.h
index 373e676bf1..b4caa7b985 100644
--- a/be/src/vec/columns/column_string.h
+++ b/be/src/vec/columns/column_string.h
@@ -342,6 +342,18 @@ public:
         SIP_HASHES_FUNCTION_COLUMN_IMPL();
     }
 
+    void update_xxHash_with_value(size_t n, uint64_t& hash) const override {
+        size_t string_size = size_at(n);
+        size_t offset = offset_at(n);
+        hash = HashUtil::xxHash64WithSeed(reinterpret_cast<const char*>(&chars[offset]),
+                                          string_size, hash);
+    }
+
+    void update_crc_with_value(size_t n, uint64_t& crc) const override {
+        auto data_ref = get_data_at(n);
+        crc = HashUtil::zlib_crc_hash(data_ref.data, data_ref.size, crc);
+    }
+
     void update_crcs_with_value(std::vector<uint64_t>& hashes, PrimitiveType type,
                                 const uint8_t* __restrict null_data) const override;
 
diff --git a/be/src/vec/columns/column_vector.h b/be/src/vec/columns/column_vector.h
index c944827fbc..1c18e810b0 100644
--- a/be/src/vec/columns/column_vector.h
+++ b/be/src/vec/columns/column_vector.h
@@ -243,6 +243,25 @@ public:
                                      const uint8_t* null_map,
                                      size_t max_row_byte_size) const override;
 
+    void update_xxHash_with_value(size_t n, uint64_t& hash) const override {
+        hash = HashUtil::xxHash64WithSeed(reinterpret_cast<const char*>(&data[n]), sizeof(T), hash);
+    }
+
+    void update_crc_with_value(size_t n, uint64_t& crc) const override {
+        if constexpr (!std::is_same_v<T, Int64>) {
+            crc = HashUtil::zlib_crc_hash(&data[n], sizeof(T), crc);
+        } else {
+            if (this->is_date_type() || this->is_datetime_type()) {
+                char buf[64];
+                const VecDateTimeValue& date_val = (const VecDateTimeValue&)data[n];
+                auto len = date_val.to_buffer(buf);
+                crc = HashUtil::zlib_crc_hash(buf, len, crc);
+            } else {
+                crc = HashUtil::zlib_crc_hash(&data[n], sizeof(T), crc);
+            }
+        }
+    }
+
     void update_hash_with_value(size_t n, SipHash& hash) const override;
 
     void update_hashes_with_value(std::vector<SipHash>& hashes,
diff --git a/be/src/vec/sink/vdata_stream_sender.cpp b/be/src/vec/sink/vdata_stream_sender.cpp
index 9768f61244..d596d78e20 100644
--- a/be/src/vec/sink/vdata_stream_sender.cpp
+++ b/be/src/vec/sink/vdata_stream_sender.cpp
@@ -569,6 +569,7 @@ Status VDataStreamSender::send(RuntimeState* state, Block* block) {
                 std::vector<SipHash> siphashs(rows);
                 // result[j] means column index, i means rows index
                 for (int j = 0; j < result_size; ++j) {
+                    // complex type most not implement get_data_at() method which column_const will call
                     block->get_by_position(result[j]).column->update_hashes_with_value(siphashs);
                 }
                 for (int i = 0; i < rows; i++) {
@@ -578,6 +579,7 @@ Status VDataStreamSender::send(RuntimeState* state, Block* block) {
                 SCOPED_TIMER(_split_block_hash_compute_timer);
                 // result[j] means column index, i means rows index, here to calculate the xxhash value
                 for (int j = 0; j < result_size; ++j) {
+                    // complex type most not implement get_data_at() method which column_const will call
                     block->get_by_position(result[j]).column->update_hashes_with_value(hashes);
                 }
 
@@ -590,6 +592,7 @@ Status VDataStreamSender::send(RuntimeState* state, Block* block) {
             RETURN_IF_ERROR(channel_add_rows(_channels, element_size, hashes, rows, block));
         } else {
             for (int j = 0; j < result_size; ++j) {
+                // complex type most not implement get_data_at() method which column_const will call
                 block->get_by_position(result[j]).column->update_crcs_with_value(
                         hash_vals, _partition_expr_ctxs[j]->root()->type().type);
             }


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


[doris] 24/38: [Fix](Export) check properties for export (#21768)

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 63f914080a72bacc84904ad392aca82d53deca16
Author: Tiewei Fang <43...@users.noreply.github.com>
AuthorDate: Fri Jul 14 00:15:12 2023 +0800

    [Fix](Export) check properties for export (#21768)
---
 .../Manipulation/EXPORT.md                         |  1 +
 .../Manipulation/EXPORT.md                         |  1 +
 .../java/org/apache/doris/analysis/ExportStmt.java | 22 +++++++++++++++++++++-
 .../java/org/apache/doris/common/FeConstants.java  |  6 +++---
 .../main/java/org/apache/doris/load/ExportJob.java | 19 +++++++++++++------
 5 files changed, 39 insertions(+), 10 deletions(-)

diff --git a/docs/en/docs/sql-manual/sql-reference/Data-Manipulation-Statements/Manipulation/EXPORT.md b/docs/en/docs/sql-manual/sql-reference/Data-Manipulation-Statements/Manipulation/EXPORT.md
index 7610722e6f..3ebf9e6f93 100644
--- a/docs/en/docs/sql-manual/sql-reference/Data-Manipulation-Statements/Manipulation/EXPORT.md
+++ b/docs/en/docs/sql-manual/sql-reference/Data-Manipulation-Statements/Manipulation/EXPORT.md
@@ -74,6 +74,7 @@ illustrate:
   - `exec_mem_limit`: Export the upper limit of the memory usage of a single BE node, the default is 2GB, and the unit is bytes.
   - `timeout`: The timeout period of the export job, the default is 2 hours, the unit is seconds.
   - `tablet_num_per_task`: The maximum number of tablets each subtask can allocate to scan.
+  - `format`: Specifies the file format, currently only supports csv, csv_with_names, csv_with_names_and_types. If without specified, the default is csv.
 
 - `WITH BROKER`
 
diff --git a/docs/zh-CN/docs/sql-manual/sql-reference/Data-Manipulation-Statements/Manipulation/EXPORT.md b/docs/zh-CN/docs/sql-manual/sql-reference/Data-Manipulation-Statements/Manipulation/EXPORT.md
index a64e0034ee..9e79d854a6 100644
--- a/docs/zh-CN/docs/sql-manual/sql-reference/Data-Manipulation-Statements/Manipulation/EXPORT.md
+++ b/docs/zh-CN/docs/sql-manual/sql-reference/Data-Manipulation-Statements/Manipulation/EXPORT.md
@@ -74,6 +74,7 @@ WITH BROKER
   - `exec_mem_limit`:导出在单个 BE 节点的内存使用上限,默认为 2GB,单位为字节。
   - `timeout`:导出作业的超时时间,默认为2小时,单位是秒。
   - `tablet_num_per_task`:每个子任务能分配扫描的最大 Tablet 数量。
+  - `format`:指定导出的格式,当前只支持csv、csv_with_names、csv_with_names_and_types。在不指定的情况下,默认为csv。
 
 - `WITH BROKER`
 
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/ExportStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/ExportStmt.java
index eb35fe4c0d..132cfa3f77 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ExportStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ExportStmt.java
@@ -39,6 +39,7 @@ import org.apache.doris.qe.ConnectContext;
 import com.google.common.base.Joiner;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
+import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Maps;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
@@ -63,6 +64,18 @@ public class ExportStmt extends StatementBase {
     private static final String DEFAULT_COLUMN_SEPARATOR = "\t";
     private static final String DEFAULT_LINE_DELIMITER = "\n";
     private static final String DEFAULT_COLUMNS = "";
+
+    private static final ImmutableSet<String> PROPERTIES_SET = new ImmutableSet.Builder<String>()
+            .add(ExportStmt.LABEL)
+            .add(LoadStmt.EXEC_MEM_LIMIT)
+            .add(LoadStmt.TIMEOUT_PROPERTY)
+            .add(ExportStmt.TABLET_NUMBER_PER_TASK_PROP)
+            .add(LoadStmt.KEY_IN_PARAM_COLUMNS)
+            .add("line_delimiter")
+            .add("column_separator")
+            .add("format")
+            .build();
+
     private TableName tblName;
     private List<String> partitions;
     private Expr whereExpr;
@@ -271,7 +284,6 @@ public class ExportStmt extends StatementBase {
                 properties, ExportStmt.DEFAULT_COLUMN_SEPARATOR));
         this.lineDelimiter = Separator.convertSeparator(PropertyAnalyzer.analyzeLineDelimiter(
                 properties, ExportStmt.DEFAULT_LINE_DELIMITER));
-        this.columns = properties.get(LoadStmt.KEY_IN_PARAM_COLUMNS);
         // exec_mem_limit
         if (properties.containsKey(LoadStmt.EXEC_MEM_LIMIT)) {
             try {
@@ -315,6 +327,14 @@ public class ExportStmt extends StatementBase {
             String label = "export_" + UUID.randomUUID().toString();
             properties.put(LABEL, label);
         }
+
+        for (String key : properties.keySet()) {
+            if (!PROPERTIES_SET.contains(key)) {
+                throw new DdlException("Invalid property key: '" + key + "'");
+            }
+        }
+
+        this.columns = properties.get(LoadStmt.KEY_IN_PARAM_COLUMNS);
     }
 
     @Override
diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/FeConstants.java b/fe/fe-core/src/main/java/org/apache/doris/common/FeConstants.java
index 91ad6e4a61..3c3ae2864b 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/common/FeConstants.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/common/FeConstants.java
@@ -63,9 +63,9 @@ public class FeConstants {
     public static String null_string = "\\N";
 
     public static long tablet_checker_interval_ms = 20 * 1000L;
-    public static String csv = "csv";
-    public static String csv_with_names = "csv_with_names";
-    public static String csv_with_names_and_types = "csv_with_names_and_types";
+    public static final String csv = "csv";
+    public static final String csv_with_names = "csv_with_names";
+    public static final String csv_with_names_and_types = "csv_with_names_and_types";
 
     public static String text = "text";
 
diff --git a/fe/fe-core/src/main/java/org/apache/doris/load/ExportJob.java b/fe/fe-core/src/main/java/org/apache/doris/load/ExportJob.java
index 36bdaa993c..cbb6f403aa 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/load/ExportJob.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/load/ExportJob.java
@@ -285,15 +285,22 @@ public class ExportJob implements Writable {
         return types;
     }
 
-    private String genHeader(Map<String, String> properties) {
+    private String genHeader(Map<String, String> properties) throws UserException {
         String header = "";
         if (properties.containsKey("format")) {
             String headerType = properties.get("format");
-            if (headerType.equals(FeConstants.csv_with_names)) {
-                header = genNames();
-            } else if (headerType.equals(FeConstants.csv_with_names_and_types)) {
-                header = genNames();
-                header += genTypes();
+            switch (headerType) {
+                case FeConstants.csv:
+                    break;
+                case FeConstants.csv_with_names:
+                    header = genNames();
+                    break;
+                case FeConstants.csv_with_names_and_types:
+                    header = genNames();
+                    header += genTypes();
+                    break;
+                default:
+                    throw new DdlException("Unknown format for export: " + headerType);
             }
         }
         return header;


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


[doris] 07/38: Revert "[Fix](Planner) Set inline view output as non constant after analyze (#21186)" (#21584)

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 7b880f98d0ec456e63efeac4cd9d857d333fad50
Author: starocean999 <40...@users.noreply.github.com>
AuthorDate: Thu Jul 6 20:30:18 2023 +0800

    Revert "[Fix](Planner) Set inline view output as non constant after analyze (#21186)" (#21584)
    
    This reverts commit d7323f0df6e0bee0f8f73f32eddfb65c3f20461d.
---
 .../main/java/org/apache/doris/analysis/Expr.java  |  7 -----
 .../java/org/apache/doris/analysis/SelectStmt.java |  4 ---
 .../org/apache/doris/analysis/QueryStmtTest.java   | 17 ++++++++--
 .../conditional_functions/test_nullif.out          |  4 ---
 .../conditional_functions/test_nullif.groovy       | 36 ----------------------
 5 files changed, 14 insertions(+), 54 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java
index f2074ae376..abed221866 100755
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java
@@ -441,13 +441,6 @@ public abstract class Expr extends TreeNode<Expr> implements ParseNode, Cloneabl
         isAnalyzed = true;
     }
 
-    /**
-     * Set the expr isConstant parameter, when select list return it can not be constant
-     */
-    public void setIsConstant(boolean isConstant) {
-        this.isConstant = isConstant;
-    }
-
     protected void computeNumDistinctValues() {
         if (isConstant()) {
             numDistinctValues = 1;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
index 7c91e33188..d634b5fb62 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
@@ -453,10 +453,6 @@ public class SelectStmt extends QueryStmt {
                     // Analyze the resultExpr before generating a label to ensure enforcement
                     // of expr child and depth limits (toColumn() label may call toSql()).
                     item.getExpr().analyze(analyzer);
-                    // select list output must not be constant because it is not scalar expression.
-                    if (!fromClause.isEmpty()) {
-                        item.getExpr().setIsConstant(false);
-                    }
                     if (!(item.getExpr() instanceof CaseExpr)
                             && item.getExpr().contains(Predicates.instanceOf(Subquery.class))) {
                         throw new AnalysisException("Subquery is not supported in the select list.");
diff --git a/fe/fe-core/src/test/java/org/apache/doris/analysis/QueryStmtTest.java b/fe/fe-core/src/test/java/org/apache/doris/analysis/QueryStmtTest.java
index 51d2199c53..03acde255d 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/analysis/QueryStmtTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/analysis/QueryStmtTest.java
@@ -210,7 +210,7 @@ public class QueryStmtTest {
         Assert.assertEquals(5, exprsMap.size());
         constMap.clear();
         constMap = getConstantExprMap(exprsMap, analyzer);
-        Assert.assertEquals(1, constMap.size());
+        Assert.assertEquals(2, constMap.size());
 
         // expr in subquery associate with column in grandparent level
         sql = "WITH aa AS\n"
@@ -261,9 +261,20 @@ public class QueryStmtTest {
     @Test
     public void testPutBackExprs() throws Exception {
         ConnectContext ctx = UtFrameUtils.createDefaultCtx();
-        String sql = "SELECT @@license, @@time_zone\n"
+        String sql = "SELECT username, @@license, @@time_zone\n"
+                + "FROM db1.table1\n"
+                + "WHERE siteid in\n"
+                + "    (SELECT abs(5+abs(0))+1)\n"
                 + "UNION\n"
-                + "SELECT @@language, @@storage_engine;";
+                + "SELECT CASE\n"
+                + "           WHEN\n"
+                + "                  (SELECT count(*)+abs(8)\n"
+                + "                   FROM db1.table1\n"
+                + "                   WHERE username='helen')>1 THEN 888\n"
+                + "           ELSE 999\n"
+                + "       END AS ccc, @@language, @@storage_engine\n"
+                + "FROM\n"
+                + "  (SELECT curdate()) a;";
         StatementBase stmt = UtFrameUtils.parseAndAnalyzeStmt(sql, ctx);
         stmt.foldConstant(new Analyzer(ctx.getEnv(), ctx).getExprRewriter());
 
diff --git a/regression-test/data/query_p0/sql_functions/conditional_functions/test_nullif.out b/regression-test/data/query_p0/sql_functions/conditional_functions/test_nullif.out
index 9675765d6d..f8def44a3d 100644
--- a/regression-test/data/query_p0/sql_functions/conditional_functions/test_nullif.out
+++ b/regression-test/data/query_p0/sql_functions/conditional_functions/test_nullif.out
@@ -480,7 +480,3 @@ null	12	1	true
 -- !if_nullif28 --
 2020-02-09
 
--- !if_nullif29 --
-1	1
-2	2
-
diff --git a/regression-test/suites/query_p0/sql_functions/conditional_functions/test_nullif.groovy b/regression-test/suites/query_p0/sql_functions/conditional_functions/test_nullif.groovy
index 2f41af96f9..e754d6d0e8 100644
--- a/regression-test/suites/query_p0/sql_functions/conditional_functions/test_nullif.groovy
+++ b/regression-test/suites/query_p0/sql_functions/conditional_functions/test_nullif.groovy
@@ -145,40 +145,4 @@ suite("test_nullif") {
     qt_if_nullif27 """select ifnull(2+3, 2), ifnull((3*1 > 1 || 1>0), 2), ifnull((3*1 > 1 or 1>0), 2),
         ifnull(upper("null"), concat("NUL", "LL"))"""
     qt_if_nullif28 """select ifnull(date(substring("2020-02-09", 1, 1024)), null)"""
-
-    def tableName2 = "testsort"
-
-    sql """ DROP TABLE IF EXISTS ${tableName2}; """
-    sql """
-            CREATE TABLE IF NOT EXISTS ${tableName2} (
-                c_int int NULL COMMENT "",
-                c_pv bitmap BITMAP_UNION NULL COMMENT ""
-            )
-            AGGREGATE KEY(c_int)
-            DISTRIBUTED BY HASH(c_int) BUCKETS 1
-            PROPERTIES (
-              "replication_num" = "1"
-            );
-        """
-    sql """ INSERT INTO ${tableName2} VALUES(1, to_bitmap(1)), (2, to_bitmap(2));"""
-
-    qt_if_nullif29 """
-	select
-	    sortNum,
-	    BITMAP_UNION_COUNT (c.pv) over (ORDER BY sortNum ) totalNum
-	from(
-	select 
-	    ifnull(a.sortNum, b.sortNum) sortNum,
-	    BITMAP_UNION (ifnull(a.c_pv, b.c_pv)) pv
-	from
-	    (select 1 sortNum, c_pv from ${tableName2} t where t.c_int = 1) a
-	full join
-	    (select 2 sortNum, c_pv from ${tableName2} t where t.c_int = 2) b
-	    on a.sortNum = b.sortNum
-	GROUP BY
-	    sortNum
-	ORDER BY
-	    sortNum
-	) c
-	;"""
 }


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


[doris] 33/38: [fix](status) fix cmake warning with message 'Manually-specified variables were not used by the project:ENABLE_STACKTRACE' (#21932)

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 435c519122661207f178d441b01f3f9f8c5dd6ad
Author: caiconghui <55...@users.noreply.github.com>
AuthorDate: Tue Jul 18 18:25:50 2023 +0800

    [fix](status) fix cmake warning with message 'Manually-specified variables were not used by the project:ENABLE_STACKTRACE' (#21932)
    
    Co-authored-by: caiconghui1 <ca...@jd.com>
---
 be/CMakeLists.txt      | 4 ++++
 be/src/common/status.h | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/be/CMakeLists.txt b/be/CMakeLists.txt
index 9307e018f0..09f607b80a 100644
--- a/be/CMakeLists.txt
+++ b/be/CMakeLists.txt
@@ -531,6 +531,10 @@ if (USE_JEMALLOC)
     set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -DUSE_JEMALLOC")
 endif()
 
+if (ENABLE_STACKTRACE)
+    add_compile_options(-DENABLE_STACKTRACE)
+endif()
+
 # STRICT_MEMORY_USE=ON` expects BE to use less memory, and gives priority to ensuring stability
 # when the cluster memory is limited.
 # TODO In the future, expect a dynamic soft memory limit, combined with real-time memory usage of the cluster,
diff --git a/be/src/common/status.h b/be/src/common/status.h
index cefc8d6402..6f49de3ec2 100644
--- a/be/src/common/status.h
+++ b/be/src/common/status.h
@@ -470,8 +470,8 @@ inline std::ostream& operator<<(std::ostream& ostr, const Status& status) {
     ostr << '[' << status.code_as_string() << ']';
     ostr << (status._err_msg ? status._err_msg->_msg : "");
 #ifdef ENABLE_STACKTRACE
-    if (status->_err_msg && !status->_err_msg._stack.empty()) {
-        ostr << '\n' << status->_err_msg._stack;
+    if (status._err_msg && !status._err_msg->_stack.empty()) {
+        ostr << '\n' << status._err_msg->_stack;
     }
 #endif
     return ostr;


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