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

Function build_aggregate_finalfn_expr

src/backend/parser/parse_agg.c:2187–2218  ·  view source on GitHub ↗

* Like build_aggregate_transfn_expr, but creates an expression tree for the * final function of an aggregate, rather than the transition function. */

Source from the content-addressed store, hash-verified

2185 * final function of an aggregate, rather than the transition function.
2186 */
2187void
2188build_aggregate_finalfn_expr(Oid *agg_input_types,
2189 int num_finalfn_inputs,
2190 Oid agg_state_type,
2191 Oid agg_result_type,
2192 Oid agg_input_collation,
2193 Oid finalfn_oid,
2194 Expr **finalfnexpr)
2195{
2196 List *args;
2197 int i;
2198
2199 /*
2200 * Build expr tree for final function
2201 */
2202 args = list_make1(make_agg_arg(agg_state_type, agg_input_collation));
2203
2204 /* finalfn may take additional args, which match agg's input types */
2205 for (i = 0; i < num_finalfn_inputs - 1; i++)
2206 {
2207 args = lappend(args,
2208 make_agg_arg(agg_input_types[i], agg_input_collation));
2209 }
2210
2211 *finalfnexpr = (Expr *) makeFuncExpr(finalfn_oid,
2212 agg_result_type,
2213 args,
2214 InvalidOid,
2215 agg_input_collation,
2216 COERCE_EXPLICIT_CALL);
2217 /* finalfn is currently never treated as variadic */
2218}
2219
2220/*
2221 * Convenience function to build dummy argument expressions for aggregates.

Callers 2

initialize_peraggFunction · 0.85
ExecInitAggFunction · 0.85

Calls 3

make_agg_argFunction · 0.85
lappendFunction · 0.85
makeFuncExprFunction · 0.85

Tested by

no test coverage detected