This is an automated email from the ASF dual-hosted git repository.
dataroaring 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 267a8cc9ea9 [fix](cluster key) add cluster key case (#44488)
267a8cc9ea9 is described below
commit 267a8cc9ea9e25cf66d7e1b0be645cf75e5100ce
Author: meiyi <[email protected]>
AuthorDate: Tue Nov 26 23:08:44 2024 +0800
[fix](cluster key) add cluster key case (#44488)
---
.../main/java/org/apache/doris/catalog/Table.java | 5 +-
.../glue/translator/PhysicalPlanTranslator.java | 2 +-
.../data/nereids_p0/delete/delete_cte_ck.out | 29 +++++
.../suites/nereids_p0/delete/delete_cte_ck.groovy | 123 +++++++++++++++++++++
4 files changed, 156 insertions(+), 3 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Table.java
b/fe/fe-core/src/main/java/org/apache/doris/catalog/Table.java
index d85d98a8ea5..ed37a936e10 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Table.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Table.java
@@ -40,6 +40,7 @@ import org.apache.doris.thrift.TTableDescriptor;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
@@ -393,7 +394,7 @@ public abstract class Table extends MetaObject implements
Writable, TableIf, Gso
}
public List<Column> getFullSchema() {
- return fullSchema;
+ return ImmutableList.copyOf(fullSchema);
}
// should override in subclass if necessary
@@ -403,7 +404,7 @@ public abstract class Table extends MetaObject implements
Writable, TableIf, Gso
public List<Column> getBaseSchema(boolean full) {
if (full) {
- return fullSchema;
+ return ImmutableList.copyOf(fullSchema);
} else {
return
fullSchema.stream().filter(Column::isVisible).collect(Collectors.toList());
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java
index 654ccc8ca11..56ae65ec722 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java
@@ -2695,7 +2695,7 @@ public class PhysicalPlanTranslator extends
DefaultPlanVisitor<PlanFragment, Pla
if (sortExprs.size() > olapTable.getDataSortInfo().getColNum()) {
return false;
}
- List<Column> sortKeyColumns = olapTable.getFullSchema();
+ List<Column> sortKeyColumns = new
ArrayList<>(olapTable.getFullSchema());
if (olapTable.getEnableUniqueKeyMergeOnWrite()) {
Map<Integer, Column> clusterKeyMap = new TreeMap<>();
for (Column column : olapTable.getFullSchema()) {
diff --git a/regression-test/data/nereids_p0/delete/delete_cte_ck.out
b/regression-test/data/nereids_p0/delete/delete_cte_ck.out
new file mode 100644
index 00000000000..2734e5b4a33
--- /dev/null
+++ b/regression-test/data/nereids_p0/delete/delete_cte_ck.out
@@ -0,0 +1,29 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !sql --
+1 \N 2 1 1.0 \N
+1 10 1 1 1.0 2000-01-01
+2 \N 4 2 2.0 \N
+2 20 2 2 2.0 2000-01-02
+3 \N 6 3 3.0 \N
+3 30 3 3 3.0 2000-01-03
+
+-- !sql --
+2 \N 4 2 2.0 \N
+2 20 2 2 2.0 2000-01-02
+3 \N 6 3 3.0 \N
+3 30 3 3 3.0 2000-01-03
+
+-- !sql --
+1 \N 2 1 1.0 \N
+1 10 1 1 1.0 2000-01-01
+2 \N 4 2 2.0 \N
+2 20 2 2 2.0 2000-01-02
+3 \N 6 3 3.0 \N
+3 30 3 3 3.0 2000-01-03
+
+-- !sql --
+2 \N 4 2 2.0 \N
+2 20 2 2 2.0 2000-01-02
+3 \N 6 3 3.0 \N
+3 30 3 3 3.0 2000-01-03
+
diff --git a/regression-test/suites/nereids_p0/delete/delete_cte_ck.groovy
b/regression-test/suites/nereids_p0/delete/delete_cte_ck.groovy
new file mode 100644
index 00000000000..2e9bd1f8fb3
--- /dev/null
+++ b/regression-test/suites/nereids_p0/delete/delete_cte_ck.groovy
@@ -0,0 +1,123 @@
+// 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('nereids_delete_cte_ck') {
+
+ String db = context.config.getDbNameByFile(context.file)
+ sql "select 1;" // to create database
+
+ for (def use_row_store : [false, true]) {
+ logger.info("current params: use_row_store: ${use_row_store}")
+
+ connect(user = context.config.jdbcUser, password =
context.config.jdbcPassword, url = context.config.jdbcUrl) {
+ sql "use ${db};"
+
+ def t1 = 't1_cte_ck'
+ def t2 = 't2_cte_ck'
+ def t3 = 't3_cte_ck'
+
+ sql "drop table if exists ${t1}"
+ sql """
+ create table ${t1} (
+ id int,
+ id1 int,
+ c1 bigint,
+ c2 string,
+ c3 double,
+ c4 date
+ ) unique key (id, id1)
+ CLUSTER BY (`id1`, `id`, `c4`)
+ distributed by hash(id, id1)
+ properties(
+ "replication_num"="1",
+ "enable_unique_key_merge_on_write" = "true",
+ "store_row_column" = "${use_row_store}"); """
+
+ sql "drop table if exists ${t2}"
+ sql """
+ create table ${t2} (
+ id int,
+ c1 bigint,
+ c2 string,
+ c3 double,
+ c4 date
+ ) unique key (id)
+ CLUSTER BY (`c4`, `c1`)
+ distributed by hash(id)
+ properties(
+ "replication_num"="1"
+ );
+ """
+
+ sql "drop table if exists ${t3}"
+ sql """
+ create table ${t3} (
+ id int
+ ) distributed by hash(id)
+ properties(
+ "replication_num"="1"
+ );
+ """
+
+ sql """
+ INSERT INTO ${t1} VALUES
+ (1, 10, 1, '1', 1.0, '2000-01-01'),
+ (2, 20, 2, '2', 2.0, '2000-01-02'),
+ (3, 30, 3, '3', 3.0, '2000-01-03');
+ """
+
+ sql """
+
+ INSERT INTO ${t2} VALUES
+ (1, 10, '10', 10.0, '2000-01-10'),
+ (2, 20, '20', 20.0, '2000-01-20'),
+ (3, 30, '30', 30.0, '2000-01-30'),
+ (4, 4, '4', 4.0, '2000-01-04'),
+ (5, 5, '5', 5.0, '2000-01-05');
+ """
+
+ sql """
+ INSERT INTO ${t3} VALUES
+ (1),
+ (4),
+ (5);
+ """
+
+ sql "set enable_nereids_planner=true"
+ sql "set enable_fallback_to_original_planner=false"
+ sql "set enable_nereids_dml=true"
+
+ sql "insert into ${t1}(id, c1, c2, c3) select id, c1 * 2, c2, c3
from ${t1}"
+ sql "insert into ${t2}(id, c1, c2, c3) select id, c1, c2 * 2, c3
from ${t2}"
+ sql "insert into ${t2}(c1, c3) select c1 + 1, c3 + 1 from (select
id, c1, c3 from ${t1} order by id, c1 limit 10) ${t1}, ${t3}"
+
+ qt_sql "select * from ${t1} order by id, id1"
+
+ sql """
+ with cte as (select * from ${t3})
+ delete from ${t1}
+ using ${t2} join cte on ${t2}.id = cte.id
+ where ${t1}.id = ${t2}.id;
+ """
+
+ qt_sql "select * from ${t1} order by id, id1"
+
+ // test cte != null and using == null
+ sql """with cte as (select 1) delete from ${t1} where ${t1}.id =
100"""
+ }
+ }
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]