Skip to content

Commit

Permalink
[fix](Nereids) npe when delete with cte and without using (#39379)
Browse files Browse the repository at this point in the history
  • Loading branch information
morrySnow authored Aug 15, 2024
1 parent 755221b commit ae27e92
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,9 @@ public LogicalPlan visitDelete(DeleteContext ctx) {
partitionSpec.second, query);
} else {
// convert to insert into select
query = withRelations(query, ctx.relations().relation());
if (ctx.USING() != null) {
query = withRelations(query, ctx.relations().relation());
}
query = withFilter(query, Optional.ofNullable(ctx.whereClause()));
Optional<LogicalPlan> cte = Optional.empty();
if (ctx.cte() != null) {
Expand Down
3 changes: 3 additions & 0 deletions regression-test/suites/nereids_p0/delete/delete_cte.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ suite('nereids_delete_cte') {
"""

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"""
}
}
}

0 comments on commit ae27e92

Please sign in to comment.