Cherry-picked from #53541 Co-authored-by: 924060929 <lanhuajian@selectdb.com>
This commit is contained in:
committed by
GitHub
parent
850360c1c4
commit
77ff75b954
@ -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());
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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 """
|
||||
|
||||
Reference in New Issue
Block a user