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

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


The following commit(s) were added to refs/heads/branch-3.1 by this push:
     new 5ca653a15a1 branch-3.1: [opt](nereids) use one fragment to execute 
point query #53541 (#53575)
5ca653a15a1 is described below

commit 5ca653a15a1cd1343ce9632fb391427d2a19e146
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Sat Jul 19 09:31:10 2025 +0800

    branch-3.1: [opt](nereids) use one fragment to execute point query #53541 
(#53575)
    
    Cherry-picked from #53541
    
    Co-authored-by: 924060929 <[email protected]>
---
 .../doris/nereids/properties/ChildOutputPropertyDeriver.java   |  4 ++++
 .../java/org/apache/doris/qe/ShortCircuitQueryContext.java     |  6 ++++--
 regression-test/suites/point_query_p0/test_point_query.groovy  | 10 ++++++++++
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/ChildOutputPropertyDeriver.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/ChildOutputPropertyDeriver.java
index fa0e90ba9a8..312ecb140c4 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/ChildOutputPropertyDeriver.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/properties/ChildOutputPropertyDeriver.java
@@ -169,6 +169,10 @@ public class ChildOutputPropertyDeriver extends 
PlanVisitor<PhysicalProperties,
 
     @Override
     public PhysicalProperties visitPhysicalOlapScan(PhysicalOlapScan olapScan, 
PlanContext context) {
+        // make sure only one fragment when use point query
+        if (context.getStatementContext().isShortCircuitQuery() && 
olapScan.getSelectedTabletIds().size() == 1) {
+            return PhysicalProperties.GATHER;
+        }
         return new PhysicalProperties(olapScan.getDistributionSpec());
     }
 
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/qe/ShortCircuitQueryContext.java 
b/fe/fe-core/src/main/java/org/apache/doris/qe/ShortCircuitQueryContext.java
index 7452b57b400..057368fc3f8 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/ShortCircuitQueryContext.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/ShortCircuitQueryContext.java
@@ -42,6 +42,7 @@ import java.util.stream.Collectors;
 public class ShortCircuitQueryContext {
     // Cached for better CPU performance, since serialize DescriptorTable and
     // outputExprs are heavy work
+    public final Planner planner;
     public final ByteString serializedDescTable;
     public final ByteString serializedOutputExpr;
     public final ByteString serializedQueryOptions;
@@ -79,13 +80,14 @@ public class ShortCircuitQueryContext {
     }
 
     public ShortCircuitQueryContext(Planner planner, Queriable analzyedQuery) 
throws TException {
+        this.planner = planner;
         this.serializedDescTable = ByteString.copyFrom(
                 new 
TSerializer().serialize(planner.getDescTable().toThrift()));
         TQueryOptions options = planner.getQueryOptions() != null ? 
planner.getQueryOptions() : new TQueryOptions();
         this.serializedQueryOptions = ByteString.copyFrom(
                 new TSerializer().serialize(options));
         List<TExpr> exprs = new ArrayList<>();
-        OlapScanNode olapScanNode = (OlapScanNode) 
planner.getFragments().get(1).getPlanRoot();
+        OlapScanNode olapScanNode = (OlapScanNode) 
planner.getScanNodes().get(0);
         if (olapScanNode.getProjectList() != null) {
             // project on scan node
             exprs.addAll(olapScanNode.getProjectList().stream()
@@ -99,7 +101,7 @@ public class ShortCircuitQueryContext {
         serializedOutputExpr = ByteString.copyFrom(
                 new TSerializer().serialize(exprList));
         this.cacheID = UUID.randomUUID();
-        this.scanNode = ((OlapScanNode) planner.getScanNodes().get(0));
+        this.scanNode = olapScanNode;
         this.tbl = this.scanNode.getOlapTable();
         this.schemaVersion = this.tbl.getBaseSchemaVersion();
         this.analzyedQuery = analzyedQuery;
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 dc8a7f01679..c550b61c14a 100644
--- a/regression-test/suites/point_query_p0/test_point_query.groovy
+++ b/regression-test/suites/point_query_p0/test_point_query.groovy
@@ -458,6 +458,16 @@ suite("test_point_query", "nonConcurrent") {
     sql "set enable_short_circuit_query = true"
     qt_sql "select length(loc3) from table_with_chars where col1 = 10"
 
+    def ensure_one_fragment = {
+        sql "set enable_nereids_planner=true"
+        explain {
+            sql "select * from table_with_chars where col1 = 10"
+            check { explainStr ->
+                assertEquals(1, explainStr.count("PLAN FRAGMENT"))
+            }
+        }
+    }()
+
     // test variant type
     sql "DROP TABLE IF EXISTS test_with_variant"
     sql """


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

Reply via email to