This is an automated email from the ASF dual-hosted git repository.
gavinchou 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 c9fb76b5579 [fix](delete) fix insert into cols should be corresponding
to the query output for delete from command (#47406)
c9fb76b5579 is described below
commit c9fb76b55790c75cb630c8087e06a29f42ab2052
Author: meiyi <[email protected]>
AuthorDate: Sun Jan 26 14:58:42 2025 +0800
[fix](delete) fix insert into cols should be corresponding to the query
output for delete from command (#47406)
for mow table with `function_column.sequence_col` map, if use `delete
from` command and run into partial update, may get:
```
errCode = 2, detailMessage = insert into cols should be corresponding to
the query output
```
---
.../trees/plans/commands/DeleteFromCommand.java | 3 +-
.../delete/delete_mow_partial_update.out | Bin 887 -> 1148 bytes
.../delete/delete_mow_partial_update.groovy | 45 +++++++++++++++++++++
3 files changed, 47 insertions(+), 1 deletion(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/DeleteFromCommand.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/DeleteFromCommand.java
index 55215323e70..be6254dabb1 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/DeleteFromCommand.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/DeleteFromCommand.java
@@ -475,7 +475,8 @@ public class DeleteFromCommand extends Command implements
ForwardWithSync, Expla
expr = new UnboundAlias(new TinyIntLiteral(((byte) 1)),
Column.DELETE_SIGN);
} else if (column.getName().equalsIgnoreCase(Column.SEQUENCE_COL)
&& targetTable.getSequenceMapCol() != null) {
- expr = new UnboundSlot(tableName,
targetTable.getSequenceMapCol());
+ expr = new UnboundAlias(new UnboundSlot(tableName,
targetTable.getSequenceMapCol()),
+ Column.SEQUENCE_COL);
} else if (column.isKey()) {
expr = new UnboundSlot(tableName, column.getName());
} else if (!isMow && (!column.isVisible() ||
(!column.isAllowNull() && !column.hasDefaultValue()))) {
diff --git
a/regression-test/data/nereids_p0/delete/delete_mow_partial_update.out
b/regression-test/data/nereids_p0/delete/delete_mow_partial_update.out
index 54b9aa4cee9..1a090023156 100644
Binary files
a/regression-test/data/nereids_p0/delete/delete_mow_partial_update.out and
b/regression-test/data/nereids_p0/delete/delete_mow_partial_update.out differ
diff --git
a/regression-test/suites/nereids_p0/delete/delete_mow_partial_update.groovy
b/regression-test/suites/nereids_p0/delete/delete_mow_partial_update.groovy
index a03a9a92fa7..680b26a4e4a 100644
--- a/regression-test/suites/nereids_p0/delete/delete_mow_partial_update.groovy
+++ b/regression-test/suites/nereids_p0/delete/delete_mow_partial_update.groovy
@@ -146,4 +146,49 @@ suite('nereids_delete_mow_partial_update') {
sql "drop table if exists ${tableName3};"
}
}
+
+ def tableName = "nereids_delete_mow_partial_update10"
+ sql "DROP TABLE IF EXISTS ${tableName};"
+ sql """
+ CREATE TABLE ${tableName} (
+ `l_shipdate` date NOT NULL,
+ `l_orderkey` bigint NOT NULL,
+ `l_linenumber` bigint NOT NULL,
+ `l_partkey` bigint NOT NULL,
+ `l_suppkey` bigint NOT NULL,
+ `l_quantity` decimal(15,2) NOT NULL,
+ `l_extendedprice` decimal(15,2) NOT NULL,
+ `l_discount` decimal(15,2) NOT NULL,
+ `l_tax` decimal(15,2) NOT NULL,
+ `l_returnflag` varchar(1) NOT NULL,
+ `l_linestatus` varchar(1) NOT NULL,
+ `l_commitdate` date NOT NULL,
+ `l_receiptdate` date NOT NULL,
+ `l_shipinstruct` varchar(25) NOT NULL,
+ `l_shipmode` varchar(10) NOT NULL,
+ `l_comment` varchar(44) NOT NULL
+ )
+ UNIQUE KEY(`l_shipdate`, `l_orderkey`, `l_linenumber`, `l_partkey`,
`l_suppkey`)
+ DISTRIBUTED BY HASH(`l_orderkey`) BUCKETS 1
+ PROPERTIES (
+ "replication_allocation" = "tag.location.default: 1",
+ "enable_unique_key_merge_on_write" = "true",
+ "function_column.sequence_col" = "l_Shipdate"
+ );
+ """
+ sql """
+ insert into ${tableName} values
+ ('2023-12-09', 1, 2, 3, 4, 5.5, 6.5, 7.5, 8.5, 'o', 'k',
'2023-12-09', '2023-12-10', 'a', 'b', 'yyyyyyyyy'),
+ ('2023-12-09', 2, 2, 3, 4, 5.5, 6.5, 7.5, 8.5, 'o', 'k',
'2023-12-09', '2023-12-10', 'a', 'b', 'yyyyyyyyy') ;
+ """
+ explain {
+ sql """ delete from ${tableName} where l_orderkey = 800; """
+ contains "IS_PARTIAL_UPDATE: true"
+ }
+ sql """ delete from ${tableName} where l_orderkey = 800; """
+ sql "sync"
+ order_qt_sql """ SELECT * FROM ${tableName}; """
+ sql """ delete from ${tableName} where l_orderkey = 2; """
+ sql "sync"
+ order_qt_sql """ SELECT * FROM ${tableName}; """
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]