This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new 6e60025d4c6 branch-2.1: [fix](nereids) add equals for some unbound
expressions #55060 (#55139)
6e60025d4c6 is described below
commit 6e60025d4c6806c3e391c1648b205621274fdf25
Author: yujun <[email protected]>
AuthorDate: Wed Aug 27 18:31:53 2025 +0800
branch-2.1: [fix](nereids) add equals for some unbound expressions #55060
(#55139)
cherry pick from #55060
---
.../doris/nereids/analyzer/UnboundAlias.java | 21 +++++++++++++
.../doris/nereids/analyzer/UnboundVariable.java | 17 +++++++++++
.../session_variable/test_variable_between.out | Bin 0 -> 412 bytes
.../session_variable/test_variable_between.groovy | 33 +++++++++++++++++++++
4 files changed, 71 insertions(+)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundAlias.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundAlias.java
index 043542eaac6..692f8f28318 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundAlias.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundAlias.java
@@ -29,6 +29,7 @@ import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
+import java.util.Objects;
import java.util.Optional;
/**
@@ -75,6 +76,26 @@ public class UnboundAlias extends NamedExpression implements
UnaryExpression, Un
}
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ if (!super.equals(o)) {
+ return false;
+ }
+ UnboundAlias other = (UnboundAlias) o;
+ return alias.equals(other.alias) && nameFromChild ==
other.nameFromChild;
+ }
+
+ @Override
+ public int computeHashCode() {
+ return Objects.hash(alias, nameFromChild, children());
+ }
+
@Override
public String toString() {
StringBuilder stringBuilder = new StringBuilder();
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundVariable.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundVariable.java
index dfd4e7fd46e..340008bcc0a 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundVariable.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundVariable.java
@@ -54,6 +54,23 @@ public class UnboundVariable extends Expression implements
Unbound {
return false;
}
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ UnboundVariable other = (UnboundVariable) o;
+ return name.equals(other.name) && type.equals(other.type);
+ }
+
+ @Override
+ public int computeHashCode() {
+ return Objects.hash(name, type);
+ }
+
@Override
public String toString() throws UnboundException {
if (type == VariableType.USER) {
diff --git
a/regression-test/data/nereids_p0/session_variable/test_variable_between.out
b/regression-test/data/nereids_p0/session_variable/test_variable_between.out
new file mode 100644
index 00000000000..462fe841ba1
Binary files /dev/null and
b/regression-test/data/nereids_p0/session_variable/test_variable_between.out
differ
diff --git
a/regression-test/suites/nereids_p0/session_variable/test_variable_between.groovy
b/regression-test/suites/nereids_p0/session_variable/test_variable_between.groovy
new file mode 100644
index 00000000000..c2124a86d76
--- /dev/null
+++
b/regression-test/suites/nereids_p0/session_variable/test_variable_between.groovy
@@ -0,0 +1,33 @@
+// 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_variable_between') {
+ multi_sql """
+ SET enable_nereids_planner=true;
+ SET enable_fallback_to_original_planner=false;
+ SET disable_nereids_rules='PRUNE_EMPTY_PARTITION';
+ SET ignore_shape_nodes='PhysicalDistribute';
+ """
+
+ sql "drop table if exists tbl_test_variable_between force"
+ sql "create table tbl_test_variable_between(a int, b int)
properties('replication_num' = '1')"
+ sql "set @beginValue = 1"
+ sql "set @endValue = 100"
+ qt_1 "explain shape plan select * from tbl_test_variable_between where a
between @beginValue and @endValue"
+ qt_2 "explain shape plan select * from tbl_test_variable_between where a
between @@runtime_bloom_filter_min_size and @@runtime_bloom_filter_max_size"
+ sql "drop table if exists tbl_test_variable_between force"
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]