leborchuk commented on PR #1762:
URL: https://github.com/apache/cloudberry/pull/1762#issuecomment-4810240769

   ### 2. Shared Scan Column Pruning
   
   LGTM, while at the beginning, I was confused by the number of fixes needed 
to make it work. However, after thorough investigation and reading, I think 
that remapping columns using `change_varattnos_of_ShareInputScan()` is quite 
safe, and there is no need for additional GUC protection. We could simply fix 
all issues if there were only one left.
   
   Initially I started with commit 54930251e4c but there is nothing  it's 
preparing commit for further improvements
   
   Commit | Date | Subject | Note
   -- | -- | -- | --
   54930251e4c | 2025-10-27 | Insert Result node atop CTE producer for column 
projection optimization | The message describes exactly this feature, but the 
actual diff does not implement Result-node insertion or column pruning. It only 
refactors Shared Scan predicate-pushdown control flow. Treat it as misleading / 
not the implementation commit.
   
   The main work is done there
   
   Commit | Date | Subject | Note
   -- | -- | -- | --
   abbb9469062 | 2025-11-28 | Implement Shared Scan column pruning. | This is 
the commit that actually implements the feature described: tracking used CTE 
consumer columns, building an attribute mapping, inserting a producer-side 
projection, and remapping consumer target lists.
   
   The fixes in logic
   
   Commit | Date | Subject | Note
   -- | -- | -- | --
   065983a1e69 | 2025-12-05 | Fix NULL check for CTE attribute map in setrefs | 
Fixes null handling around the CTE attribute map introduced by pruning.
   a2711ef5ac9 | 2026-01-02 | Fix Shared Scan target list varattno adjustment | 
Fixes attribute-number remapping after pruning.
   31c97bfee5a | 2026-01-02 | Fix ShareInputScan target list construction | 
Fixes target-list construction for Shared Scan after projection changes.
   51b3f681a03 | 2026-01-03 | Fix logic for correcting Shared Scan target list 
varattno | Further fixes varattno correction logic.
   fdd9e8fee2b | 2026-01-03 | Fix assertion for subquery unused column handling 
| Fixes assertion failures around unused/pruned columns.
   b2cf7a4f0fb | 2026-01-08 | Handle whole-row references in Shared Scan 
projection | Handles cases like selecting the whole CTE row, where pruning 
cannot safely remove columns.
   d8c98164156 | 2026-01-09 | Remove unnecessary nodes from SharedScan subquery 
| Cleans up unnecessary nodes after the Shared Scan projection work.
   
   I didn't check all of them using gdb, so I cannot say that they actually 
fixed all the issues that were described. I just read the description and 
checked the logic and saw no issues. We gradually came to a solution when 
everything perform inside `change_varatnos_of_shareinputscan()` and so we just 
needed not to forget that `varatno == 0` was a special case for `select 
table.*` and that we needed to replace only references related to the shared 
CTE, not any matching references.
   
   
   
    


-- 
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