This is an automated email from the ASF dual-hosted git repository.
yiguolei 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 77ff75b954c branch-2.1: [opt](nereids) use one fragment to execute
point query #53541 (#53574)
77ff75b954c is described below
commit 77ff75b954c82a3da71887732a3b92cf83c238d7
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri Jul 25 14:02:06 2025 +0800
branch-2.1: [opt](nereids) use one fragment to execute point query #53541
(#53574)
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 270712496e9..94a362ea716 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
@@ -166,6 +166,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 2840dd65239..4f01e6c2307 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
@@ -41,6 +41,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;
@@ -61,13 +62,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()
@@ -81,7 +83,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 3962d76c51c..037d9a29073 100644
--- a/regression-test/suites/point_query_p0/test_point_query.groovy
+++ b/regression-test/suites/point_query_p0/test_point_query.groovy
@@ -420,6 +420,16 @@ suite("test_point_query", "nonConcurrent") {
}
}
+ 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]