[Enhancement] Add column prune support for VOlapScanNode (#10615)
This commit is contained in:
@ -788,6 +788,7 @@ public class HashJoinNode extends PlanNode {
|
||||
}
|
||||
output.append("\n");
|
||||
}
|
||||
|
||||
if (hashOutputSlotIds != null) {
|
||||
output.append(detailPrefix).append("hash output slot ids: ");
|
||||
for (SlotId slotId : hashOutputSlotIds) {
|
||||
@ -795,6 +796,7 @@ public class HashJoinNode extends PlanNode {
|
||||
}
|
||||
output.append("\n");
|
||||
}
|
||||
appendCommonExplainString(detailPrefix, output);
|
||||
return output.toString();
|
||||
}
|
||||
|
||||
|
||||
@ -26,6 +26,7 @@ import org.apache.doris.analysis.InPredicate;
|
||||
import org.apache.doris.analysis.IntLiteral;
|
||||
import org.apache.doris.analysis.PartitionNames;
|
||||
import org.apache.doris.analysis.SlotDescriptor;
|
||||
import org.apache.doris.analysis.SlotId;
|
||||
import org.apache.doris.analysis.SlotRef;
|
||||
import org.apache.doris.analysis.TupleDescriptor;
|
||||
import org.apache.doris.analysis.TupleId;
|
||||
@ -48,6 +49,7 @@ import org.apache.doris.catalog.Tablet;
|
||||
import org.apache.doris.common.AnalysisException;
|
||||
import org.apache.doris.common.ErrorCode;
|
||||
import org.apache.doris.common.ErrorReport;
|
||||
import org.apache.doris.common.NotImplementedException;
|
||||
import org.apache.doris.common.UserException;
|
||||
import org.apache.doris.common.util.Util;
|
||||
import org.apache.doris.qe.ConnectContext;
|
||||
@ -744,7 +746,7 @@ public class OlapScanNode extends ScanNode {
|
||||
output.append(prefix).append(String.format("cardinality=%s", cardinality))
|
||||
.append(String.format(", avgRowSize=%s", avgRowSize)).append(String.format(", numNodes=%s", numNodes));
|
||||
output.append("\n");
|
||||
|
||||
appendCommonExplainString(prefix, output);
|
||||
return output.toString();
|
||||
}
|
||||
|
||||
@ -940,4 +942,17 @@ public class OlapScanNode extends ScanNode {
|
||||
return DataPartition.RANDOM;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initOutputSlotIds(Set<SlotId> requiredSlotIdSet, Analyzer analyzer) throws NotImplementedException {
|
||||
outputSlotIds = Lists.newArrayList();
|
||||
for (TupleId tupleId : tupleIds) {
|
||||
for (SlotDescriptor slotDescriptor : analyzer.getTupleDesc(tupleId).getSlots()) {
|
||||
if (slotDescriptor.isMaterialized() && (requiredSlotIdSet == null || requiredSlotIdSet.contains(
|
||||
slotDescriptor.getId())) || slotDescriptor.getColumn().getName().equals(Column.DELETE_SIGN)) {
|
||||
outputSlotIds.add(slotDescriptor.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -986,4 +986,17 @@ public abstract class PlanNode extends TreeNode<PlanNode> implements PlanStats {
|
||||
sb.append("\n").append(getNodeExplainString("", TExplainLevel.BRIEF));
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to append some common explains to output
|
||||
*/
|
||||
protected void appendCommonExplainString(String detailPrefix, StringBuilder output) {
|
||||
if (outputSlotIds != null) {
|
||||
output.append(detailPrefix).append("output slot ids: ");
|
||||
for (SlotId slotId : outputSlotIds) {
|
||||
output.append(slotId).append(" ");
|
||||
}
|
||||
output.append("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,4 +108,35 @@ public class ProjectPlannerFunctionTest {
|
||||
Assert.assertTrue(explainString.contains("output slot ids: 1"));
|
||||
Assert.assertTrue(explainString.contains("hash output slot ids: 1 2 3"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void projectOlap() throws Exception {
|
||||
String createOrdersTbl = "CREATE TABLE test.`orders` (\n" + " `o_orderkey` integer NOT NULL,\n"
|
||||
+ " `o_custkey` integer NOT NULL,\n" + " `o_orderstatus` char(1) NOT NULL,\n"
|
||||
+ " `o_totalprice` decimal(12, 2) NOT NULL,\n" + " `o_orderdate` date NOT NULL,\n"
|
||||
+ " `o_orderpriority` char(15) NOT NULL,\n" + " `o_clerk` char(15) NOT NULL,\n"
|
||||
+ " `o_shippriority` integer NOT NULL,\n" + " `o_comment` varchar(79) NOT NULL\n"
|
||||
+ ") DISTRIBUTED BY HASH(`o_orderkey`) BUCKETS 32 PROPERTIES (\"replication_num\" = \"1\");";
|
||||
CreateTableStmt createTableStmt = (CreateTableStmt) UtFrameUtils.parseAndAnalyzeStmt(createOrdersTbl, connectContext);
|
||||
Catalog.getCurrentCatalog().createTable(createTableStmt);
|
||||
|
||||
String createCustomerTbl = "CREATE TABLE test.`customer` (\n" + " `c_custkey` integer NOT NULL,\n"
|
||||
+ " `c_name` varchar(25) NOT NULL,\n" + " `c_address` varchar(40) NOT NULL,\n"
|
||||
+ " `c_nationkey` integer NOT NULL,\n" + " `c_phone` char(15) NOT NULL,\n"
|
||||
+ " `c_acctbal` decimal(12, 2) NOT NULL,\n" + " `c_mktsegment` char(10) NOT NULL,\n"
|
||||
+ " `c_comment` varchar(117) NOT NULL\n"
|
||||
+ ") DISTRIBUTED BY HASH(`c_custkey`) BUCKETS 32 PROPERTIES (\"replication_num\" = \"1\");";
|
||||
createTableStmt = (CreateTableStmt) UtFrameUtils.parseAndAnalyzeStmt(createCustomerTbl, connectContext);
|
||||
Catalog.getCurrentCatalog().createTable(createTableStmt);
|
||||
String tpcH13 = "select\n" + " c_count,\n" + " count(*) as custdist\n" + "from\n" + " (\n"
|
||||
+ " select\n" + " c_custkey,\n" + " count(o_orderkey) as c_count\n"
|
||||
+ " from\n" + " test.customer left outer join test.orders on\n"
|
||||
+ " c_custkey = o_custkey\n"
|
||||
+ " and o_comment not like '%special%requests%'\n" + " group by\n"
|
||||
+ " c_custkey\n" + " ) as c_orders\n" + "group by\n" + " c_count\n" + "order by\n"
|
||||
+ " custdist desc,\n" + " c_count desc;";
|
||||
String explainString = UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, tpcH13);
|
||||
Assert.assertTrue(explainString.contains("output slot ids: 1 3"));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user