ViktorBystrov72 opened a new pull request, #60601:
URL: https://github.com/apache/spark/pull/60601

   ### What changes were proposed in this pull request?
   
   Keep left semi and left anti joins above a Python UDTF's Generate node. This 
protects the required input sorting for partitioned or ordered TABLE arguments. 
Add optimizer and execution regressions and a migration note.
   
   ### Why are the changes needed?
   
   [SPARK-61734](https://issues.apache.org/jira/browse/SPARK-61734) reports 
that a constant-false anti join changes a deterministic, partition-counting 
UDTF's results. Generic unary-operator pushdown moves the join between Generate 
and its input Sort. EliminateSorts can then remove the required ordering before 
the join is simplified away, splitting each key into several runs.
   
   The exclusion conservatively applies to Python UDTFs; ordinary native 
generators remain eligible for this optimization.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. A partitioned UDTF over interleaved date keys still returns two groups 
with count 2 after an always-false anti join. Previously, the same query 
returned four groups with count 1.
   
   ### How was this patch tested?
   
   Before the fix, all 16 new Python-UDTF plan cases and both execution 
regressions fail. The two native Generate pushdown controls pass.
   
   - Complete `LeftSemiAntiJoinPushDownSuite` and `EliminateSortsSuite`: 146 
tests passed.
   - Focused `PythonUDTFSuite` execution/partition/order coverage: 4 tests 
passed.
   - Catalyst production/test and SQL test ScalaStyle: passed.
   - Apache RAT: passed with the repository exclusions plus the `.git` worktree 
metadata file.
   
   The optimizer cases cover both Python eval types, semi/anti joins, and 
false, null, absent, and key conditions. Actual worker execution uses the 
non-Arrow UDTF path and verifies both a NULL condition and an equality 
conjoined with false. The SQL suite emitted possible-daemon-thread-leak 
warnings in baseline and patched runs; patched checks exited successfully.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: OpenAI Codex (gpt-6.1-sol; exact tool build unavailable). 
Codex assisted with the Scala implementation, regression tests and their 
embedded Python fixture, migration note, and this description.
   


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