Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1326,6 +1326,9 @@ private void trySetPartialUpdate() throws UserException {
&& partialUpdateCols.contains(olapTable.getSequenceMapCol())) {
partialUpdateCols.add(Column.SEQUENCE_COL);
}

partialUpdateCols.add(Column.DELETE_SIGN);

// we should re-generate olapTuple
DescriptorTable descTable = analyzer.getDescTbl();
olapTuple = descTable.createTupleDescriptor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,11 @@ public PlanFragment visitPhysicalOlapTableSink(PhysicalOlapTableSink<? extends P
for (Column col : olapTableSink.getCols()) {
partialUpdateCols.add(col.getName());
}
if (olapTableSink.getTargetTable() instanceof OlapTable
&& olapTableSink.getTargetTable().hasDeleteSign()
&& olapTableSink.getTargetTable().getDeleteSignColumn() != null) {
partialUpdateCols.add(Column.DELETE_SIGN);
}
}
TupleDescriptor olapTuple = context.generateTupleDesc();
List<Column> targetTableColumns = olapTableSink.getTargetTable().getFullSchema();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,13 @@ private static Map<String, NamedExpression> getColumnToOutput(
new ExpressionRewriteContext(ctx.cascadesContext));
columnToOutput.put(column.getName(),
new Alias(defualtValueExpression, column.getName()));
} else if (table instanceof OlapTable && ((OlapTable) table).hasDeleteSign()
&& column.getName().equals(Column.DELETE_SIGN)
&& column.getDefaultValue() != null) {
columnToOutput.put(column.getName(),
new Alias(Literal.of(column.getDefaultValue())
.checkedCastTo(DataType.fromCatalogType(column.getType())),
column.getName()));
} else {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
-- This file is automatically generated. You should know what you did if you want to edit this

-- !1 --
1 doris 1000 123 1
2 doris2 2000 223 1
Expand Down Expand Up @@ -82,6 +83,12 @@
3 300 2 3
4 400 1 2

-- !11 --
1 100

-- !12 --
2 200

-- !1 --
1 doris 1000 123 1
2 doris2 2000 223 1
Expand Down Expand Up @@ -165,3 +172,9 @@
3 300 2 3
4 400 1 2

-- !11 --
1 100

-- !12 --
2 200

Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,47 @@ suite("nereids_partial_update_native_insert_stmt", "p0") {
sql "set enable_insert_strict = false;"
sql "set enable_fallback_to_original_planner=true;"
sql "sync;"

// test native paitial update insert after delete
// in nereids
sql "set enable_unique_key_partial_update=true;"
sql "set enable_insert_strict = false;"
sql "set enable_fallback_to_original_planner=false;"
sql "set experimental_enable_nereids_planner=true;"
sql "sync;"
def tableName10 = "nereids_partial_update_native_insert_stmt10"
sql """ DROP TABLE IF EXISTS ${tableName10} """
sql """create table ${tableName10} (
k int null,
v int null
) unique key (k) distributed by hash(k) buckets 1
properties("replication_num" = "1",
"enable_unique_key_merge_on_write"="true",
"disable_auto_compaction"="true",
"store_row_column" = "${use_row_store}"); """

sql "insert into ${tableName10}(k,v) values(1,100);"
sql "delete from ${tableName10} where k like '%%';"
sql "insert into ${tableName10}(k,v) values(1,100);"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution, but this PR can't fix the issue. e.g.
If your table's schema have 3 columns, say k, v1, v2
then insert with values (1, 100, 200);
then delete them all
then you set enable_unique_key_partial_update=true, and insert into ${tableName10}(k,v1) values(1,100);, you should expect to get a result 1, 100, null, but actually you will get a resut 1, 100, 200.

qt_11 "select * from ${tableName10} order by k;"
sql "delete from ${tableName10} where k=1;"

// in origin planner
sql "set experimental_enable_nereids_planner = false;"
sql "sync;"
sql "insert into ${tableName10}(k,v) values(2,200);"
sql "delete from ${tableName10} where k like '%%';"
sql "insert into ${tableName10}(k,v) values(2,200);"
qt_12 "select * from ${tableName10} order by k;"

sql "set enable_unique_key_partial_update=false;"
sql "set enable_insert_strict = true;"
sql "set enable_nereids_dml=true;"
sql "set experimental_enable_nereids_planner=true;"
sql "set enable_fallback_to_original_planner=false;"
sql "sync;"
sql """ DROP TABLE IF EXISTS ${tableName10}; """

}
}
}