Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ public PhysicalProperties visitPhysicalOdbcScan(PhysicalOdbcScan odbcScan, PlanC

@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());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
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;
Expand Down Expand Up @@ -79,13 +80,14 @@ List<Type> getReturnTypes() {
}

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()
Expand All @@ -99,7 +101,7 @@ public ShortCircuitQueryContext(Planner planner, Queriable analzyedQuery) throws
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;
Expand Down
10 changes: 10 additions & 0 deletions regression-test/suites/point_query_p0/test_point_query.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,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 """
Expand Down
Loading