This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new b9161295b7 [Fix](plan) fix bug that the case sensibility of column
name may impact join method (#17904)
b9161295b7 is described below
commit b9161295b77ed4420cc66b859e28ce96a480af72
Author: GoGoWen <[email protected]>
AuthorDate: Tue Mar 28 15:18:30 2023 +0800
[Fix](plan) fix bug that the case sensibility of column name may impact
join method (#17904)
Issue Number: close #17876
---
.../apache/doris/planner/DistributedPlanner.java | 8 ++--
.../casesensetive_column/ddl/ad_order_data.sql | 15 +++++++
.../casesensetive_column/ddl/ad_order_data_v1.sql | 15 +++++++
.../join_with_column_casesensetive.groovy | 48 ++++++++++++++++++++++
4 files changed, 83 insertions(+), 3 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/planner/DistributedPlanner.java
b/fe/fe-core/src/main/java/org/apache/doris/planner/DistributedPlanner.java
index 203146164a..0537ec5bab 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/DistributedPlanner.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/DistributedPlanner.java
@@ -654,10 +654,11 @@ public class DistributedPlanner {
DistributionInfo leftDistribution =
leftScanNode.getOlapTable().getDefaultDistributionInfo();
if (leftDistribution instanceof HashDistributionInfo) {
- // use the table_name + '-' + column_name as check condition
+ // use the table_name + '-' + column_name.toLowerCase() as check
condition,
+ // as column name in doris is case insensitive and table name is
case sensitive
List<Column> leftDistributeColumns = ((HashDistributionInfo)
leftDistribution).getDistributionColumns();
List<String> leftDistributeColumnNames =
leftDistributeColumns.stream()
- .map(col -> leftTable.getName() + "." +
col.getName()).collect(Collectors.toList());
+ .map(col -> leftTable.getName() + "." +
col.getName().toLowerCase()).collect(Collectors.toList());
List<String> leftJoinColumnNames = new ArrayList<>();
List<Expr> rightExprs = new ArrayList<>();
@@ -675,7 +676,8 @@ public class DistributedPlanner {
&&
leftScanNode.desc.getSlots().contains(leftSlot.getDesc())) {
// table name in SlotRef is not the really name. `select *
from test as t`
// table name in SlotRef is `t`, but here we need is
`test`.
- leftJoinColumnNames.add(leftSlot.getTable().getName() +
"." + leftSlot.getColumnName());
+ leftJoinColumnNames.add(leftSlot.getTable().getName() + "."
+ + leftSlot.getColumnName().toLowerCase());
rightExprs.add(rhsJoinExpr);
}
}
diff --git
a/regression-test/suites/query_p0/casesensetive_column/ddl/ad_order_data.sql
b/regression-test/suites/query_p0/casesensetive_column/ddl/ad_order_data.sql
new file mode 100644
index 0000000000..592d776ed3
--- /dev/null
+++ b/regression-test/suites/query_p0/casesensetive_column/ddl/ad_order_data.sql
@@ -0,0 +1,15 @@
+CREATE TABLE `ad_order_data` (
+ `pin_id` bigint(20) NOT NULL,
+ `date_time` datetime NOT NULL COMMENT '点击时间',
+ `order_day` datetime NOT NULL COMMENT '下单时间',
+ `rptcnt` bigint(20) SUM NULL DEFAULT "0",
+ `rptgmv` bigint(20) SUM NULL DEFAULT "0"
+) ENGINE=OLAP
+AGGREGATE KEY(`pin_id`, `date_time`, `order_day`)
+COMMENT 'OLAP'
+DISTRIBUTED BY HASH(`pin_id`) BUCKETS 16
+PROPERTIES (
+"replication_allocation" = "tag.location.default: 1",
+"in_memory" = "false",
+"storage_format" = "V2"
+);
\ No newline at end of file
diff --git
a/regression-test/suites/query_p0/casesensetive_column/ddl/ad_order_data_v1.sql
b/regression-test/suites/query_p0/casesensetive_column/ddl/ad_order_data_v1.sql
new file mode 100644
index 0000000000..09650cc507
--- /dev/null
+++
b/regression-test/suites/query_p0/casesensetive_column/ddl/ad_order_data_v1.sql
@@ -0,0 +1,15 @@
+CREATE TABLE `ad_order_data_v1` (
+ `pin_id` bigint(20) NOT NULL,
+ `date_time` datetime NOT NULL COMMENT '点击时间',
+ `order_day` datetime NOT NULL COMMENT '下单时间',
+ `rptcnt` bigint(20) SUM NULL DEFAULT "0",
+ `rptgmv` bigint(20) SUM NULL DEFAULT "0"
+) ENGINE=OLAP
+AGGREGATE KEY(`pin_id`, `date_time`, `order_day`)
+COMMENT 'OLAP'
+DISTRIBUTED BY HASH(`pin_id`) BUCKETS 16
+PROPERTIES (
+"replication_allocation" = "tag.location.default: 1",
+"in_memory" = "false",
+"storage_format" = "V2"
+);
\ No newline at end of file
diff --git
a/regression-test/suites/query_p0/casesensetive_column/join_with_column_casesensetive.groovy
b/regression-test/suites/query_p0/casesensetive_column/join_with_column_casesensetive.groovy
new file mode 100644
index 0000000000..7874ba71d1
--- /dev/null
+++
b/regression-test/suites/query_p0/casesensetive_column/join_with_column_casesensetive.groovy
@@ -0,0 +1,48 @@
+// 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("join_with_column_casesensetive") {
+ def tables=["ad_order_data_v1","ad_order_data"]
+
+ for (String table in tables) {
+ sql """ DROP TABLE IF EXISTS $table """
+ }
+
+ for (String table in tables) {
+ sql new File("""${context.file.parent}/ddl/${table}.sql""").text
+ }
+
+ explain {
+ sql("select ad_order_data.pin_id, ad_order_data_v1.rptcnt from
ad_order_data left join ad_order_data_v1 on
ad_order_data.pin_id=ad_order_data_v1.pin_id;")
+ notContains "PIN_ID"
+ }
+
+ explain {
+ sql("select ad_order_data.pin_id, ad_order_data_v1.rptcnt from
ad_order_data left join ad_order_data_v1 on
ad_order_data.PIN_ID=ad_order_data_v1.PIN_ID;")
+ contains "PIN_ID"
+ }
+
+ def result1 = sql """
+ explain select ad_order_data.pin_id, ad_order_data_v1.rptcnt from
ad_order_data left join ad_order_data_v1 on
ad_order_data.pin_id=ad_order_data_v1.pin_id;
+ """
+
+ def result2 = sql """
+ explain select ad_order_data.pin_id, ad_order_data_v1.rptcnt from
ad_order_data left join ad_order_data_v1 on
ad_order_data.PIN_ID=ad_order_data_v1.PIN_ID;
+ """
+
+ assertEquals(result1.toString().toLowerCase(),
result2.toString().toLowerCase())
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]