MCPcopy Create free account
hub / github.com/apache/cloudberry / create_windowagg_path

Function create_windowagg_path

src/backend/optimizer/util/pathnode.c:5597–5643  ·  view source on GitHub ↗

* create_windowagg_path * Creates a pathnode that represents computation of window functions * * 'rel' is the parent relation associated with the result * 'subpath' is the path representing the source of data * 'target' is the PathTarget to be computed * 'windowFuncs' is a list of WindowFunc structs * 'winclause' is a WindowClause that is common to all the WindowFuncs * * The input must

Source from the content-addressed store, hash-verified

5595 * plus ORDER BY keys.
5596 */
5597WindowAggPath *
5598create_windowagg_path(PlannerInfo *root,
5599 RelOptInfo *rel,
5600 Path *subpath,
5601 PathTarget *target,
5602 List *windowFuncs,
5603 WindowClause *winclause)
5604{
5605 WindowAggPath *pathnode = makeNode(WindowAggPath);
5606
5607 pathnode->path.pathtype = T_WindowAgg;
5608 pathnode->path.parent = rel;
5609 pathnode->path.pathtarget = target;
5610 /* For now, assume we are above any joins, so no parameterization */
5611 pathnode->path.param_info = NULL;
5612 pathnode->path.parallel_aware = false;
5613 pathnode->path.parallel_safe = rel->consider_parallel &&
5614 subpath->parallel_safe;
5615 pathnode->path.parallel_workers = subpath->parallel_workers;
5616 /* WindowAgg preserves the input sort order */
5617 pathnode->path.pathkeys = subpath->pathkeys;
5618 pathnode->path.locus = subpath->locus;
5619
5620 pathnode->subpath = subpath;
5621 pathnode->winclause = winclause;
5622
5623 /*
5624 * For costing purposes, assume that there are no redundant partitioning
5625 * or ordering columns; it's not worth the trouble to deal with that
5626 * corner case here. So we just pass the unmodified list lengths to
5627 * cost_windowagg.
5628 */
5629 cost_windowagg(&pathnode->path, root,
5630 windowFuncs,
5631 list_length(winclause->partitionClause),
5632 list_length(winclause->orderClause),
5633 subpath->startup_cost,
5634 subpath->total_cost,
5635 subpath->rows);
5636
5637 /* add tlist eval cost for each output row */
5638 pathnode->path.startup_cost += target->cost.startup;
5639 pathnode->path.total_cost += target->cost.startup +
5640 target->cost.per_tuple * pathnode->path.rows;
5641
5642 return pathnode;
5643}
5644
5645/*
5646 * create_setop_path

Callers 2

create_one_window_pathFunction · 0.85

Calls 2

cost_windowaggFunction · 0.85
list_lengthFunction · 0.85

Tested by

no test coverage detected