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

Function transformScatterClause

src/backend/parser/parse_clause.c:3311–3345  ·  view source on GitHub ↗

* transformScatterClause - * transform a SCATTER BY clause * * SCATTER BY items will be added to the targetlist (as resjunk columns) * if not already present, so the targetlist must be passed by reference. * */

Source from the content-addressed store, hash-verified

3309 *
3310 */
3311List *
3312transformScatterClause(ParseState *pstate,
3313 List *scatterlist,
3314 List **targetlist)
3315{
3316 List *outlist = NIL;
3317 ListCell *olitem;
3318
3319 /* Special case handling for SCATTER RANDOMLY */
3320 if (list_length(scatterlist) == 1 && linitial(scatterlist) == NULL)
3321 return list_make1(NULL);
3322
3323 /* preprocess the scatter clause, lookup TLEs */
3324 foreach(olitem, scatterlist)
3325 {
3326 Node *node = lfirst(olitem);
3327 TargetEntry *tle;
3328
3329 tle = findTargetlistEntrySQL99(pstate, node, targetlist,
3330 EXPR_KIND_SCATTER_BY);
3331
3332 /* coerce unknown to text */
3333 if (exprType((Node *) tle->expr) == UNKNOWNOID)
3334 {
3335 tle->expr = (Expr *) coerce_type(pstate, (Node *) tle->expr,
3336 UNKNOWNOID, TEXTOID, -1,
3337 COERCION_IMPLICIT,
3338 COERCE_IMPLICIT_CAST,
3339 -1);
3340 }
3341
3342 outlist = lappend(outlist, tle->expr);
3343 }
3344 return outlist;
3345}
3346
3347/*
3348 * get_matching_location

Callers 1

transformSelectStmtFunction · 0.85

Calls 6

list_lengthFunction · 0.85
findTargetlistEntrySQL99Function · 0.85
exprTypeFunction · 0.85
coerce_typeFunction · 0.85
lappendFunction · 0.85
foreachFunction · 0.50

Tested by

no test coverage detected