This is an automated email from the ASF dual-hosted git repository.

kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git

commit f41066e6932c725ee4534d86ddef14fb29a338de
Author: lihangyu <[email protected]>
AuthorDate: Sun Oct 8 14:05:41 2023 +0800

    [Fix](point query) Not allow subquery for point query optimization (#25085)
---
 .../java/org/apache/doris/analysis/SelectStmt.java |  4 +++
 .../suites/point_query_p0/test_update.groovy       | 39 ++++++++++++++++++++++
 2 files changed, 43 insertions(+)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
index 797237dba51..f19e513f8e2 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
@@ -2622,6 +2622,10 @@ public class SelectStmt extends QueryStmt {
         if (tbl.getTable().getType() != Table.TableType.OLAP) {
             return false;
         }
+        // ensure no sub query
+        if (!analyzer.isRootAnalyzer()) {
+            return false;
+        }
         OlapTable olapTable = (OlapTable) tbl.getTable();
         Preconditions.checkNotNull(eqPredicates);
         eqPredicates = getExpectedBinaryPredicates(eqPredicates, whereClause, 
TExprOpcode.EQ);
diff --git a/regression-test/suites/point_query_p0/test_update.groovy 
b/regression-test/suites/point_query_p0/test_update.groovy
new file mode 100644
index 00000000000..32e4fce8233
--- /dev/null
+++ b/regression-test/suites/point_query_p0/test_update.groovy
@@ -0,0 +1,39 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_update", "p0") {
+    sql """
+        create table if not exists test (
+        workspace_id int not null comment "Workspace id",
+        user_id varchar(64) comment "External user id",
+        tenant_id int not null comment "Tenant id",
+        created_at datetime not null default current_timestamp(0) comment 
"Created at",
+        updated_at datetime comment "Updated at"
+        )
+        engine=olap
+        unique key (workspace_id, user_id)
+        distributed by hash(workspace_id, user_id)
+        properties (
+        "replication_num" = "1",
+        "enable_unique_key_merge_on_write" = "true",
+        "light_schema_change" = "true",
+        "store_row_column" = "true"
+        );
+    """
+    sql """insert into test (workspace_id, user_id, tenant_id) values (1, 
'asdfadfa', 1);"""
+    sql """update test set tenant_id = 5 where workspace_id = 1 and user_id = 
'asdfadfa';"""
+}
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to