This is an automated email from the ASF dual-hosted git repository.
morrysnow pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new ec0e4133172 [fix](Nereids) npe when delete with cte and without using
(#39379) (#39441)
ec0e4133172 is described below
commit ec0e413317262341c9dc73fb187cbec35c9d6ec0
Author: morrySnow <[email protected]>
AuthorDate: Fri Aug 16 13:56:24 2024 +0800
[fix](Nereids) npe when delete with cte and without using (#39379) (#39441)
pick from master #39379
---
.../main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java | 4 +++-
regression-test/suites/nereids_p0/delete/delete_cte.groovy | 3 +++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
index 309b98bc906..ad2aa783307 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
@@ -931,7 +931,9 @@ public class LogicalPlanBuilder extends
DorisParserBaseVisitor<Object> {
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) {
diff --git a/regression-test/suites/nereids_p0/delete/delete_cte.groovy
b/regression-test/suites/nereids_p0/delete/delete_cte.groovy
index 080c760b51e..711ba1dac4f 100644
--- a/regression-test/suites/nereids_p0/delete/delete_cte.groovy
+++ b/regression-test/suites/nereids_p0/delete/delete_cte.groovy
@@ -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"""
}
}
}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]