jiaqizho commented on code in PR #1883:
URL: https://github.com/apache/cloudberry/pull/1883#discussion_r3718771972


##########
src/backend/gporca/libgpopt/src/operators/CPhysicalCTEConsumer.cpp:
##########
@@ -45,12 +46,30 @@ CPhysicalCTEConsumer::CPhysicalCTEConsumer(CMemoryPool *mp, 
ULONG id,
        m_pdrgpcr = GPOS_NEW(mp) CColRefArray(mp);
        m_pidxmap = GPOS_NEW(mp) ULongPtrArray(mp);
 
+       // ShareInputScan does not project, so the producer finalizes its 
shared-scan
+       // output as the union of all consumers' required columns (see
+       // CTranslatorDXLToExpr::PruneCTEs). Therefore every consumer must 
expose
+       // exactly the producer's surviving columns: it can neither read a 
column the
+       // producer pruned (that would run past the shared tuple) nor decide 
what to
+       // keep from its own per-column usage. Drive the consumer's kept set 
from the
+       // producer's used mask, which is the single source of truth. When the
+       // producer was not pruned (mask is NULL) fall back to the previous 
behavior.
+       CCTEInfo *pcteinfo = COptCtxt::PoctxtFromTLS()->Pcteinfo();
+       CLogicalCTEProducer *popProducer =
+               
CLogicalCTEProducer::PopConvert(pcteinfo->PexprCTEProducer(m_id)->Pop());
+       BOOL *producer_umask = popProducer->UsedMask();

Review Comment:
   nit: Since `producer_umask` represents the finalized layout and is only read 
here, declared as const BOOL *?
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to