unspecifiedcoder opened a new pull request, #27859:
URL: https://github.com/apache/datafusion/pull/27859

   ## Which issue does this PR close?
   
   Closes #27830.
   
   ## Rationale for this change
   
   A correlated EXISTS query with nested filters on count(*) can fail with a 
missing-column error on some runs and return the expected rows on others. A 
smaller case with one filter followed by a derived-table alias fails 
consistently.
   
   ## What changes are included in this PR?
   
   Use unnormalize_col when the first pulled-up filter is stored, matching the 
convention already used for later filters. This keeps an old reference such as 
w1.n from escaping its alias scope and competing with n when the projection 
collects required columns.
   
   ## What is the testing strategy for this PR?
   
   The 14 cases in `subquery_count_filters.slt` cover the deterministic 
failure, repeated and distinct aliases, filters on matched and empty-input 
counts, NOT EXISTS, projected EXISTS, renamed outputs, duplicate and NULL outer 
rows, and an empty inner table. The expected results were also checked with 
SQLite.
   
   The deterministic case fails without the fix. The regression tests, 
optimizer tests, extended workspace tests, CLI tests, formatting and 
workspace-wide Clippy all pass. The extended run also passed all 311 SQL test 
files.
   
   ## Are there any user-facing changes?
   
   The affected queries return their expected rows consistently instead of 
intermittently failing with a schema error.
   


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