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

Function assign_ordered_set_collations

src/backend/parser/parse_collate.c:923–948  ·  view source on GitHub ↗

* For ordered-set aggregates, it's somewhat unclear how best to proceed. * The spec-defined inverse distribution functions have only one sort column * and don't return collatable types, but this is clearly too restrictive in * the general case. Our solution is to consider that the aggregate's direct * arguments contribute normally to determination of the aggregate's own * collation, while ag

Source from the content-addressed store, hash-verified

921 * Otherwise this is much like the plain-aggregate case.
922 */
923static void
924assign_ordered_set_collations(Aggref *aggref,
925 assign_collations_context *loccontext)
926{
927 bool merge_sort_collations;
928 ListCell *lc;
929
930 /* Merge sort collations to parent only if there can be only one */
931 merge_sort_collations = (list_length(aggref->args) == 1 &&
932 get_func_variadictype(aggref->aggfnoid) == InvalidOid);
933
934 /* Direct args, if any, are normal children of the Aggref node */
935 (void) assign_collations_walker((Node *) aggref->aggdirectargs,
936 loccontext);
937
938 /* Process aggregated args appropriately */
939 foreach(lc, aggref->args)
940 {
941 TargetEntry *tle = lfirst_node(TargetEntry, lc);
942
943 if (merge_sort_collations)
944 (void) assign_collations_walker((Node *) tle, loccontext);
945 else
946 assign_expr_collations(loccontext->pstate, (Node *) tle);
947 }
948}
949
950/*
951 * Hypothetical-set aggregates are even more special: per spec, we need to

Callers 1

assign_collations_walkerFunction · 0.85

Calls 5

list_lengthFunction · 0.85
get_func_variadictypeFunction · 0.85
assign_collations_walkerFunction · 0.85
assign_expr_collationsFunction · 0.85
foreachFunction · 0.50

Tested by

no test coverage detected