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

Function finalize_grouping_exprs_walker

src/backend/parser/parse_agg.c:1565–1706  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1563}
1564
1565static bool
1566finalize_grouping_exprs_walker(Node *node,
1567 check_ungrouped_columns_context *context)
1568{
1569 ListCell *gl;
1570
1571 if (node == NULL)
1572 return false;
1573 if (IsA(node, Const) ||
1574 IsA(node, Param))
1575 return false; /* constants are always acceptable */
1576
1577 if (IsA(node, Aggref))
1578 {
1579 Aggref *agg = (Aggref *) node;
1580
1581 if ((int) agg->agglevelsup == context->sublevels_up)
1582 {
1583 /*
1584 * If we find an aggregate call of the original level, do not
1585 * recurse into its normal arguments, ORDER BY arguments, or
1586 * filter; GROUPING exprs of this level are not allowed there. But
1587 * check direct arguments as though they weren't in an aggregate.
1588 */
1589 bool result;
1590
1591 Assert(!context->in_agg_direct_args);
1592 context->in_agg_direct_args = true;
1593 result = finalize_grouping_exprs_walker((Node *) agg->aggdirectargs,
1594 context);
1595 context->in_agg_direct_args = false;
1596 return result;
1597 }
1598
1599 /*
1600 * We can skip recursing into aggregates of higher levels altogether,
1601 * since they could not possibly contain exprs of concern to us (see
1602 * transformAggregateCall). We do need to look at aggregates of lower
1603 * levels, however.
1604 */
1605 if ((int) agg->agglevelsup > context->sublevels_up)
1606 return false;
1607 }
1608
1609 if (IsA(node, GroupingFunc))
1610 {
1611 GroupingFunc *grp = (GroupingFunc *) node;
1612
1613 /*
1614 * We only need to check GroupingFunc nodes at the exact level to
1615 * which they belong, since they cannot mix levels in arguments.
1616 */
1617
1618 if ((int) grp->agglevelsup == context->sublevels_up)
1619 {
1620 ListCell *lc;
1621 List *ref_list = NIL;
1622

Callers 1

finalize_grouping_exprsFunction · 0.85

Calls 10

flatten_join_alias_varsFunction · 0.85
equalFunction · 0.85
parser_errpositionFunction · 0.85
exprLocationFunction · 0.85
lappend_intFunction · 0.85
query_tree_walkerFunction · 0.85
expression_tree_walkerFunction · 0.85
foreachFunction · 0.50
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected