Skip to content

Commit

Permalink
[Fix](point query) Not allow subquery for point query optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
eldenmoon committed Oct 7, 2023
1 parent 20a7df6 commit 62a9e8d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2622,6 +2622,10 @@ public int compare(SlotRef o1, SlotRef o2) {
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);
Expand Down
39 changes: 39 additions & 0 deletions regression-test/suites/point_query_p0/test_update.groovy
Original file line number Diff line number Diff line change
@@ -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';"""
}

0 comments on commit 62a9e8d

Please sign in to comment.