yihua opened a new pull request, #20858:
URL: https://github.com/apache/hudi/pull/20858

   ### Describe the issue this Pull Request addresses
   
   Closes #20842.
   
   A Spark SQL DELETE whose condition is always false (`WHERE false`, `WHERE 1 
> null`, `WHERE name = null`) still writes an empty commit, so every such 
statement adds an instant to the timeline.
   
   ### Summary and Changelog
   
   Spark's optimizer already turns the filter of such a condition into an empty 
`LocalRelation`, so `DeleteHoodieTableCommand` (Spark 3 and Spark 4 copies) now 
returns before the write when its optimized input is one. A DELETE whose 
condition is evaluated against the rows still commits when it matches nothing, 
as before.
   
   The new test in `TestDeleteTable` runs on COW and MOR, with and without 
optimized SQL writes, and checks that the always-false conditions leave the 
commit count unchanged while `21 = 21` still deletes every row through a 
commit. It fails without the fix with `Expected 1, but got 2`.
   
   ### Impact
   
   An always-false Spark SQL DELETE no longer creates an empty commit. Since no 
commit is written, nothing that runs off a commit (inline table services, meta 
sync, commit callbacks) runs for such a statement either.
   
   ### Risk Level
   
   low
   
   Only plans the optimizer reduced to an empty relation are skipped, and those 
can't delete anything.
   
   ### Documentation Update
   
   none
   
   ### Contributor's checklist
   
   - [x] Read through [contributor's 
guide](https://hudi.apache.org/contribute/how-to-contribute)
   - [x] Enough context is provided in the sections above
   - [x] Adequate tests were added if applicable
   


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

Reply via email to