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

Function cdbpathlocus_get_distkey_exprs

src/backend/cdb/cdbpathlocus.c:564–607  ·  view source on GitHub ↗

* cdbpathlocus_get_distkey_exprs * * Returns a List with one Expr for each distkey column. Each item either is * in the given targetlist, or has no Var nodes that are not in the targetlist; * and uses only rels in the given set of relids. Returns NIL if the * distkey cannot be expressed in terms of the given relids and targetlist. */

Source from the content-addressed store, hash-verified

562 * distkey cannot be expressed in terms of the given relids and targetlist.
563 */
564void
565cdbpathlocus_get_distkey_exprs(CdbPathLocus locus,
566 Bitmapset *relids,
567 List *targetlist,
568 List **exprs_p,
569 List **opfamilies_p)
570{
571 List *result_exprs = NIL;
572 List *result_opfamilies = NIL;
573 ListCell *distkeycell;
574
575 Assert(cdbpathlocus_is_valid(locus));
576
577 *exprs_p = NIL;
578 *opfamilies_p = NIL;
579
580 if (CdbPathLocus_IsHashed(locus) || CdbPathLocus_IsHashedOJ(locus) || CdbPathLocus_IsHashedWorkers(locus))
581 {
582 foreach(distkeycell, locus.distkey)
583 {
584 DistributionKey *distkey = (DistributionKey *) lfirst(distkeycell);
585 ListCell *ec_cell;
586 Expr *item = NULL;
587
588 foreach(ec_cell, distkey->dk_eclasses)
589 {
590 EquivalenceClass *dk_eclass = (EquivalenceClass *) lfirst(ec_cell);
591
592 item = cdbpullup_findEclassInTargetList(dk_eclass, targetlist,
593 distkey->dk_opfamily, NULL);
594
595 if (item)
596 break;
597 }
598 if (!item)
599 return;
600
601 result_exprs = lappend(result_exprs, item);
602 result_opfamilies = lappend_oid(result_opfamilies, distkey->dk_opfamily);
603 }
604 *exprs_p = result_exprs;
605 *opfamilies_p = result_opfamilies;
606 }
607} /* cdbpathlocus_get_distkey_exprs */
608
609
610/*

Callers 1

Calls 5

cdbpathlocus_is_validFunction · 0.85
lappendFunction · 0.85
lappend_oidFunction · 0.85
foreachFunction · 0.50

Tested by

no test coverage detected