Skip to content

Commit 2ebf871

Browse files
branch-3.0 [fix](delete) fix insert into cols should be corresponding to the query output for delete from command #47406 (#47454)
Cherry-picked from #47406 Co-authored-by: meiyi <[email protected]>
1 parent 7785490 commit 2ebf871

File tree

3 files changed

+54
-1
lines changed

3 files changed

+54
-1
lines changed

fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/DeleteFromCommand.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,8 @@ public LogicalPlan completeQueryPlan(ConnectContext ctx, LogicalPlan logicalQuer
408408
expr = new UnboundAlias(new TinyIntLiteral(((byte) 1)), Column.DELETE_SIGN);
409409
} else if (column.getName().equalsIgnoreCase(Column.SEQUENCE_COL)
410410
&& targetTable.getSequenceMapCol() != null) {
411-
expr = new UnboundSlot(tableName, targetTable.getSequenceMapCol());
411+
expr = new UnboundAlias(new UnboundSlot(tableName, targetTable.getSequenceMapCol()),
412+
Column.SEQUENCE_COL);
412413
} else if (column.isKey()) {
413414
expr = new UnboundSlot(tableName, column.getName());
414415
} else if (!isMow && (!column.isVisible() || (!column.isAllowNull() && !column.hasDefaultValue()))) {

regression-test/data/nereids_p0/delete/delete_mow_partial_update.out

+7
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,10 @@
103103
4 4 4 4 4 0
104104
5 5 5 5 5 0
105105

106+
-- !sql --
107+
2023-12-09 1 2 3 4 5.50 6.50 7.50 8.50 o k 2023-12-09 2023-12-10 a b yyyyyyyyy
108+
2023-12-09 2 2 3 4 5.50 6.50 7.50 8.50 o k 2023-12-09 2023-12-10 a b yyyyyyyyy
109+
110+
-- !sql --
111+
2023-12-09 1 2 3 4 5.50 6.50 7.50 8.50 o k 2023-12-09 2023-12-10 a b yyyyyyyyy
112+

regression-test/suites/nereids_p0/delete/delete_mow_partial_update.groovy

+45
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,49 @@ suite('nereids_delete_mow_partial_update') {
146146
sql "drop table if exists ${tableName3};"
147147
}
148148
}
149+
150+
def tableName = "nereids_delete_mow_partial_update10"
151+
sql "DROP TABLE IF EXISTS ${tableName};"
152+
sql """
153+
CREATE TABLE ${tableName} (
154+
`l_shipdate` date NOT NULL,
155+
`l_orderkey` bigint NOT NULL,
156+
`l_linenumber` bigint NOT NULL,
157+
`l_partkey` bigint NOT NULL,
158+
`l_suppkey` bigint NOT NULL,
159+
`l_quantity` decimal(15,2) NOT NULL,
160+
`l_extendedprice` decimal(15,2) NOT NULL,
161+
`l_discount` decimal(15,2) NOT NULL,
162+
`l_tax` decimal(15,2) NOT NULL,
163+
`l_returnflag` varchar(1) NOT NULL,
164+
`l_linestatus` varchar(1) NOT NULL,
165+
`l_commitdate` date NOT NULL,
166+
`l_receiptdate` date NOT NULL,
167+
`l_shipinstruct` varchar(25) NOT NULL,
168+
`l_shipmode` varchar(10) NOT NULL,
169+
`l_comment` varchar(44) NOT NULL
170+
)
171+
UNIQUE KEY(`l_shipdate`, `l_orderkey`, `l_linenumber`, `l_partkey`, `l_suppkey`)
172+
DISTRIBUTED BY HASH(`l_orderkey`) BUCKETS 1
173+
PROPERTIES (
174+
"replication_allocation" = "tag.location.default: 1",
175+
"enable_unique_key_merge_on_write" = "true",
176+
"function_column.sequence_col" = "l_Shipdate"
177+
);
178+
"""
179+
sql """
180+
insert into ${tableName} values
181+
('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'),
182+
('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') ;
183+
"""
184+
explain {
185+
sql """ delete from ${tableName} where l_orderkey = 800; """
186+
contains "IS_PARTIAL_UPDATE: true"
187+
}
188+
sql """ delete from ${tableName} where l_orderkey = 800; """
189+
sql "sync"
190+
order_qt_sql """ SELECT * FROM ${tableName}; """
191+
sql """ delete from ${tableName} where l_orderkey = 2; """
192+
sql "sync"
193+
order_qt_sql """ SELECT * FROM ${tableName}; """
149194
}

0 commit comments

Comments
 (0)