diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/PointQueryExecutor.java b/fe/fe-core/src/main/java/org/apache/doris/qe/PointQueryExecutor.java index 13f6ec2a96..72a5a8e66a 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/PointQueryExecutor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/PointQueryExecutor.java @@ -44,6 +44,7 @@ import org.apache.doris.thrift.TStatusCode; import com.google.common.base.Preconditions; import com.google.common.base.Strings; +import com.google.common.collect.Maps; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.thrift.TDeserializer; @@ -53,6 +54,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; @@ -148,16 +150,18 @@ public class PointQueryExecutor implements CoordInterface { void addKeyTuples( InternalService.PTabletKeyLookupRequest.Builder requestBuilder) { // TODO handle IN predicates + Map columnExpr = Maps.newHashMap(); KeyTuple.Builder kBuilder = KeyTuple.newBuilder(); for (Expr expr : shortCircuitQueryContext.scanNode.getConjuncts()) { BinaryPredicate predicate = (BinaryPredicate) expr; Expr left = predicate.getChild(0); Expr right = predicate.getChild(1); - // ignore delete sign conjuncts only collect key conjuncts - if (left instanceof SlotRef && ((SlotRef) left).getColumnName().equalsIgnoreCase(Column.DELETE_SIGN)) { - continue; - } - kBuilder.addKeyColumnRep(right.getStringValue()); + SlotRef columnSlot = left.unwrapSlotRef(); + columnExpr.put(columnSlot.getColumnName(), right); + } + // add key tuple in keys order + for (Column column : shortCircuitQueryContext.scanNode.getOlapTable().getBaseSchemaKeyColumns()) { + kBuilder.addKeyColumnRep(columnExpr.get(column.getName()).getStringValue()); } requestBuilder.addKeyTuples(kBuilder); } diff --git a/regression-test/data/point_query_p0/test_point_query.out b/regression-test/data/point_query_p0/test_point_query.out index 1cc4142e39..3003a098a5 100644 --- a/regression-test/data/point_query_p0/test_point_query.out +++ b/regression-test/data/point_query_p0/test_point_query.out @@ -160,3 +160,6 @@ -- !sql -- -10 20 aabc update val +-- !sql -- +-10 20 aabc update val + diff --git a/regression-test/suites/point_query_p0/test_point_query.groovy b/regression-test/suites/point_query_p0/test_point_query.groovy index a1cbeba481..902c6ffa95 100644 --- a/regression-test/suites/point_query_p0/test_point_query.groovy +++ b/regression-test/suites/point_query_p0/test_point_query.groovy @@ -330,4 +330,5 @@ suite("test_point_query", "nonConcurrent") { qt_sql "select * from table_3821461 where col1 = 10 and col2 = 20 and loc3 = 'aabc';" sql "update table_3821461 set value = 'update value' where col1 = -10 or col1 = 20;" qt_sql """select * from table_3821461 where col1 = -10 and col2 = 20 and loc3 = 'aabc'""" + qt_sql """select * from table_3821461 where col2 = 20 and loc3 = 'aabc' and col1 = -10 """ } \ No newline at end of file