This is an automated email from the ASF dual-hosted git repository.
diwu 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 c2b7de8f77d [Fix](Show-Delete)Missing Delete job information causes
query exception (#30092)
c2b7de8f77d is described below
commit c2b7de8f77dbfb2d687c102f50e4000a49197c32
Author: Calvin Kirs <[email protected]>
AuthorDate: Fri Jan 19 09:51:34 2024 +0800
[Fix](Show-Delete)Missing Delete job information causes query exception
(#30092)
---
.../java/org/apache/doris/load/DeleteInfo.java | 16 +++---
.../main/java/org/apache/doris/load/DeleteJob.java | 6 +-
.../suites/show_p0/test_show_delete.groovy | 67 ++++++++++++++++++++++
3 files changed, 80 insertions(+), 9 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/load/DeleteInfo.java
b/fe/fe-core/src/main/java/org/apache/doris/load/DeleteInfo.java
index 05c6c4b1a86..89114d5beed 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/load/DeleteInfo.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/load/DeleteInfo.java
@@ -60,12 +60,19 @@ public class DeleteInfo implements Writable,
GsonPostProcessable {
@SerializedName(value = "partitionName")
private String partitionName;
- public DeleteInfo(long dbId, long tableId, String tableName, List<String>
deleteConditions) {
+ public DeleteInfo(long dbId, long tableId, String tableName, List<String>
deleteConditions,
+ boolean noPartitionSpecified, List<Long> partitionIds,
List<String> partitionNames) {
this.dbId = dbId;
this.tableId = tableId;
this.tableName = tableName;
this.deleteConditions = deleteConditions;
this.createTimeMs = System.currentTimeMillis();
+ this.noPartitionSpecified = noPartitionSpecified;
+ if (!noPartitionSpecified) {
+ Preconditions.checkState(partitionIds.size() ==
partitionNames.size());
+ this.partitionIds = partitionIds;
+ this.partitionNames = partitionNames;
+ }
}
public long getDbId() {
@@ -92,13 +99,6 @@ public class DeleteInfo implements Writable,
GsonPostProcessable {
return noPartitionSpecified;
}
- public void setPartitions(boolean noPartitionSpecified, List<Long>
partitionIds, List<String> partitionNames) {
- this.noPartitionSpecified = noPartitionSpecified;
- Preconditions.checkState(partitionIds.size() == partitionNames.size());
- this.partitionIds = partitionIds;
- this.partitionNames = partitionNames;
- }
-
public List<Long> getPartitionIds() {
return partitionIds;
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/load/DeleteJob.java
b/fe/fe-core/src/main/java/org/apache/doris/load/DeleteJob.java
index 5bb07dd7b68..a764b42773b 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/load/DeleteJob.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/load/DeleteJob.java
@@ -490,6 +490,7 @@ public class DeleteJob extends
AbstractTxnStateChangeCallback implements DeleteJ
public static class Builder {
public DeleteJob buildWith(BuildParams params) throws Exception {
+ boolean noPartitionSpecified =
params.getPartitionNames().isEmpty();
List<Partition> partitions =
getSelectedPartitions(params.getTable(),
params.getPartitionNames(), params.getDeleteConditions());
Map<Long, Short> partitionReplicaNum = partitions.stream()
@@ -504,8 +505,11 @@ public class DeleteJob extends
AbstractTxnStateChangeCallback implements DeleteJ
String label = DELETE_PREFIX + UUID.randomUUID();
//generate jobId
long jobId = Env.getCurrentEnv().getNextId();
+ List<String> partitionNames =
partitions.stream().map(Partition::getName).collect(Collectors.toList());
+ List<Long> partitionIds =
partitions.stream().map(Partition::getId).collect(Collectors.toList());
DeleteInfo deleteInfo = new DeleteInfo(params.getDb().getId(),
params.getTable().getId(),
- params.getTable().getName(),
getDeleteCondString(params.getDeleteConditions()));
+ params.getTable().getName(),
getDeleteCondString(params.getDeleteConditions()),
+ noPartitionSpecified, partitionIds, partitionNames);
DeleteJob deleteJob = new DeleteJob(jobId, -1, label,
partitionReplicaNum, deleteInfo);
long replicaNum =
partitions.stream().mapToLong(Partition::getAllReplicaCount).sum();
deleteJob.setPartitions(partitions);
diff --git a/regression-test/suites/show_p0/test_show_delete.groovy
b/regression-test/suites/show_p0/test_show_delete.groovy
new file mode 100644
index 00000000000..bc0c0c561ef
--- /dev/null
+++ b/regression-test/suites/show_p0/test_show_delete.groovy
@@ -0,0 +1,67 @@
+// 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_show_delete") {
+ def tableName = "test_show_delete_table"
+ sql """drop table if exists ${tableName}"""
+
+ sql """
+ CREATE TABLE IF NOT EXISTS ${tableName}
+ (
+ `datetime` DATE NOT NULL COMMENT "['0000-01-01', '9999-12-31']",
+ `type` TINYINT NOT NULL COMMENT "[-128, 127]",
+ `user_id` decimal(9,3) COMMENT "[-9223372036854775808,
9223372036854775807]"
+ )
+ UNIQUE KEY(`datetime`)
+ PARTITION BY RANGE(`datetime`)
+ (
+ PARTITION `Feb` VALUES LESS THAN ("2022-03-01"),
+ PARTITION `Mar` VALUES LESS THAN ("2022-04-01")
+ )
+ DISTRIBUTED BY HASH(`datetime`) BUCKETS 1
+ PROPERTIES (
+ "replication_allocation" = "tag.location.default: 1"
+ );
+ """
+
+ sql """insert into ${tableName} values ('2022-02-01', 1, 1.1),
('2022-03-01', 2, 2.2)"""
+
+ sql """ set delete_without_partition = true"""
+ // don't care nereids planner
+ sql """ delete from ${tableName} PARTITION Mar where type ='2'"""
+ sql """ delete from ${tableName} where type ='1'"""
+ def showDeleteResult = sql """ show delete"""
+ //When we test locally, multiple history results will be included, so size
will be >= 2
+ assert showDeleteResult.size() >= 2
+ def count = 0
+ showDeleteResult.each { row ->
+
+ if (row[3] == 'type EQ "2"') {
+ assert row[1] == 'Mar'
+ count++
+ return
+ }
+ if (row[3] == 'type EQ "1"') {
+ assert row[1] == '*'
+ count++
+ return
+ }
+
+ }
+ assert count == showDeleteResult.size()
+
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]