Skip to content

Commit

Permalink
[Fix](Short Circuit) fix no project list in OlapScanNode (apache#37121)
Browse files Browse the repository at this point in the history
query like

```
select a, `__DORIS_DELETE_SIGN__` from  `test_tbl` WHERE k = '1111111'
```
will not contain project list on top of OlapScanNode, so for short
circuit queries, we should use output exprs on top of plan fragment.

```
+----------------------------------------------------------------------------------------------------------------------------+
| Explain String(Nereids Planner)                                                                                            |
+----------------------------------------------------------------------------------------------------------------------------+
| PLAN FRAGMENT 0                                                                                                            |
|   OUTPUT EXPRS:                                                                                                            |
|     k1[#0]                                                                                                                 |
|     k2[#1]                                                                                                                 |
|     k3[#2]                                                                                                                 |
|     k4[#3]                                                                                                                 |
|     k5[#4]                                                                                                                 |
|     k6[#5]                                                                                                                 |
|     k7[#6]                                                                                                                 |
|     k8[apache#7]                                                                                                                 |
|     k9[apache#8]                                                                                                                 |
|     k10[apache#9]                                                                                                                |
|     k11[apache#10]                                                                                                               |
|     k12[apache#11]                                                                                                               |
|     new_column0[apache#12]                                                                                                       |
|     new_column1[apache#13]                                                                                                       |
|     __DORIS_DELETE_SIGN__[apache#14]                                                                                             |
|   PARTITION: UNPARTITIONED                                                                                                 |
|                                                                                                                            |
|   HAS_COLO_PLAN_NODE: false                                                                                                |
|                                                                                                                            |
|   VRESULT SINK                                                                                                             |
|      MYSQL_PROTOCAL                                                                                                        |
|                                                                                                                            |
|   1:VEXCHANGE                                                                                                              |
|      offset: 0                                                                                                             |
|      distribute expr lists: k1[#0], k2[#1], k3[#2]                                                                         |
|                                                                                                                            |
| PLAN FRAGMENT 1                                                                                                            |
|                                                                                                                            |
|   PARTITION: HASH_PARTITIONED: k1[#0], k2[#1], k3[#2]                                                                      |
|                                                                                                                            |
|   HAS_COLO_PLAN_NODE: false                                                                                                |
|                                                                                                                            |
|   STREAM DATA SINK                                                                                                         |
|     EXCHANGE ID: 01                                                                                                        |
|     UNPARTITIONED                                                                                                          |
|                                                                                                                            |
|   0:VOlapScanNode(149)                                                                                                     |
|      TABLE: regression_test_serving_p0.tbl_point_query0(tbl_point_query0), PREAGGREGATION: ON                              |
|      PREDICATES: (k1[#0] = 1231) AND (k2[#1] = 119291.110000000) AND (k3[#2] = 'ddd') AND (__DORIS_DELETE_SIGN__[apache#14] = 0) |
|      partitions=1/1 (tbl_point_query0)                                                                                     |
|      tablets=1/1, tabletList=13203                                                                                         |
|      cardinality=0, avgRowSize=0.0, numNodes=1                                                                             |
|      pushAggOp=NONE                                                                                                        |
|      SHORT-CIRCUIT                                                                                                         |
|                                                                                                                            |
|                                                                                                                            |
| Statistics                                                                                                                 |
|  planed with unknown column statistics                                                                                     |
+----------------------------------------------------------------------------------------------------------------------------+
```
  • Loading branch information
eldenmoon authored Jul 3, 2024
1 parent ad48d00 commit def48d5
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;

public class ShortCircuitQueryContext {
// Cached for better CPU performance, since serialize DescriptorTable and
Expand Down Expand Up @@ -66,8 +67,15 @@ public ShortCircuitQueryContext(Planner planner, Queriable analzyedQuery) throws
this.serializedQueryOptions = ByteString.copyFrom(
new TSerializer().serialize(options));
List<TExpr> exprs = new ArrayList<>();
for (Expr expr : planner.getFragments().get(1).getPlanRoot().getProjectList()) {
exprs.add(expr.treeToThrift());
OlapScanNode olapScanNode = (OlapScanNode) planner.getFragments().get(1).getPlanRoot();
if (olapScanNode.getProjectList() != null) {
// project on scan node
exprs.addAll(olapScanNode.getProjectList().stream()
.map(Expr::treeToThrift).collect(Collectors.toList()));
} else {
// add output slots
exprs.addAll(planner.getFragments().get(0).getOutputExprs().stream()
.map(Expr::treeToThrift).collect(Collectors.toList()));
}
TExprList exprList = new TExprList(exprs);
serializedOutputExpr = ByteString.copyFrom(
Expand Down
Loading

0 comments on commit def48d5

Please sign in to comment.