You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2023/06/06 06:16:14 UTC

[doris] branch branch-1.2-lts updated: [Fix](Planner) Fix function do not have equal function and substitution failed (#20479)

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

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


The following commit(s) were added to refs/heads/branch-1.2-lts by this push:
     new 8c89f14bd6 [Fix](Planner) Fix function do not have equal function and substitution failed (#20479)
8c89f14bd6 is described below

commit 8c89f14bd678fc8cc14ac30887b9cba4202e0ac2
Author: LiBinfeng <46...@users.noreply.github.com>
AuthorDate: Tue Jun 6 14:16:08 2023 +0800

    [Fix](Planner) Fix function do not have equal function and substitution failed (#20479)
    
    The problem this pr want to solved is when generating merge aggregate using original planner, partition expressions need to be substitude, but when comparing two castExpr function, it fails because super.Function does not implement equals function.
    
    Add equals implementation to Fucntion Expr
---
 .../java/org/apache/doris/catalog/Function.java    | 19 +++++++++
 .../aggregate/aggregate_grouping_function.groovy   | 46 +++++++++++++++++++++-
 2 files changed, 64 insertions(+), 1 deletion(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Function.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Function.java
index 6dc5319d93..8f40ad6219 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Function.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Function.java
@@ -38,7 +38,9 @@ import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.util.Arrays;
 import java.util.List;
+import java.util.Objects;
 
 /**
  * Base class for all functions.
@@ -834,4 +836,21 @@ public class Function implements Writable {
             throw new UserException("failed to serialize function: " + functionName(), t);
         }
     }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        Function function = (Function) o;
+        return id == function.id && hasVarArgs == function.hasVarArgs && userVisible == function.userVisible
+            && vectorized == function.vectorized && Objects.equals(name, function.name)
+            && Objects.equals(retType, function.retType) && Arrays.equals(argTypes,
+            function.argTypes) && Objects.equals(location, function.location)
+            && binaryType == function.binaryType && nullableMode == function.nullableMode && Objects.equals(
+            checksum, function.checksum);
+    }
 }
diff --git a/regression-test/suites/query_p0/aggregate/aggregate_grouping_function.groovy b/regression-test/suites/query_p0/aggregate/aggregate_grouping_function.groovy
index 65d71923f3..5cde8cebb4 100644
--- a/regression-test/suites/query_p0/aggregate/aggregate_grouping_function.groovy
+++ b/regression-test/suites/query_p0/aggregate/aggregate_grouping_function.groovy
@@ -90,4 +90,48 @@ suite("aggregate_grouping_function") {
     """
 
     sql "DROP TABLE test_aggregate_grouping_function"
-}
\ No newline at end of file
+
+    sql "DROP TABLE IF EXISTS test_aggregate_collect_set"
+ 
+    sql """
+        CREATE table test_aggregate_collect_set (
+		custr_nbr varchar(30),   
+		bar_code varchar(36),
+       		audit_id varchar(255),
+		case_id text,
+		into_time text,
+		audit_time text,
+		apply_type text,
+		node_code text,
+		audit_code1 text,
+		audit_code2 text,
+		audit_code3 text
+	) UNIQUE KEY (custr_nbr,bar_code,audit_id )
+	distributed by hash (custr_nbr,bar_code,audit_id ) buckets 10
+	properties(
+		  "replication_num" = "1"
+	);"""
+
+    sql """ INSERT into test_aggregate_collect_set values ('custr_nbr', 'barcode', 'audit_id', 'case_id', '2007-11-30 10:30:19', '2007-11-30 10:30:19', '2', 'Decline', 'c1', 'c2', 'c3');"""
+
+    sql """ 
+	SELECT
+	    tt.tag_value
+	FROM (
+	    SELECT
+	        d.custr_nbr,
+	        concat_ws('|', collect_set(d.is_code1)) as tag_value
+	    FROM (
+	        SELECT
+	            b.custr_nbr,
+	            1 as is_code1
+	        FROM test_aggregate_collect_set b
+	    ) d
+	    GROUP BY d.custr_nbr
+	) tt
+	GROUP BY tt.tag_value
+	;
+	"""
+
+    sql "DROP TABLE test_aggregate_collect_set"
+}


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