MCPcopy Create free account
hub / github.com/ByConity/ByConity / combineSubqueryOutputsToTuple

Method combineSubqueryOutputsToTuple

src/QueryPlan/QueryPlanner.cpp:2219–2244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2217}
2218
2219RelationPlan QueryPlannerVisitor::combineSubqueryOutputsToTuple(const RelationPlan & plan, const ASTPtr & subquery)
2220{
2221 const auto & outputs = plan.getFieldSymbolInfos();
2222
2223 if (outputs.size() > 1)
2224 {
2225 auto subquery_type = analysis.getExpressionType(subquery);
2226 const auto & type_tuple = typeid_cast<const DataTypeTuple &>(*subquery_type);
2227 ASTs tuple_func_args(outputs.size());
2228 std::transform(
2229 outputs.begin(), outputs.end(), tuple_func_args.begin(), [](auto & out) { return toSymbolRef(out.getPrimarySymbol()); });
2230
2231 ASTPtr tuple_func_expr = makeASTFunction("tuple", std::move(tuple_func_args));
2232 if (type_tuple.haveExplicitNames())
2233 tuple_func_expr = makeCastFunction(tuple_func_expr, subquery_type);
2234 auto tuple_func_symbol = context->getSymbolAllocator()->newSymbol(tuple_func_expr);
2235 Assignments assignments{{tuple_func_symbol, tuple_func_expr}};
2236 NameToType types{{tuple_func_symbol, subquery_type}};
2237 auto old_root = plan.getRoot();
2238 auto expression_step = std::make_shared<ProjectionStep>(old_root->getCurrentDataStream(), assignments, types);
2239 auto new_root = old_root->addStep(context->nextNodeId(), std::move(expression_step));
2240
2241 return {new_root, FieldSymbolInfos{{tuple_func_symbol}}};
2242 }
2243 return plan;
2244}
2245
2246RelationPlan QueryPlannerVisitor::planSetOperation(ASTs & selects, ASTSelectWithUnionQuery::Mode union_mode)
2247{

Callers

nothing calls this directly

Calls 13

transformFunction · 0.85
toSymbolRefFunction · 0.85
makeASTFunctionFunction · 0.85
makeCastFunctionFunction · 0.85
getExpressionTypeMethod · 0.80
haveExplicitNamesMethod · 0.80
newSymbolMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
getRootMethod · 0.45
addStepMethod · 0.45

Tested by

no test coverage detected