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

   ### Describe the issue this Pull Request addresses
   
   closes #20853
   
   A cached view of a merge-on-read table keeps returning rows that a later 
`DELETE`, `UPDATE` or `MERGE INTO` changed. The relation fixes the instant its 
file group reader merges log blocks up to when it is built, so when Spark 
re-executes the cached plan after `refreshTable`, the file index lists the new 
log files but the reader skips their blocks.
   
   ### Summary and Changelog
   
   Without a time travel instant, `HoodieFileGroupReaderBasedFileFormat` now 
reads up to the latest completed instant of the relation's meta client when it 
builds the reader, which is the timeline the file index reloads on refresh. 
`HoodieHadoopFsRelationFactory` passes only the time travel instant, if any. An 
empty timeline (a cached plan re-executed after `TRUNCATE TABLE`) falls back to 
the initial instant, since its file index lists no file slices.
   
   The new test in `TestDeleteTable` caches a view over a copy-on-write and a 
merge-on-read table and checks that it sees a later `DELETE`, `UPDATE` and 
`MERGE INTO`. Without the fix it fails with `mor table, delete: Expected 
Array(), but got Array([1,a1])`. A test in `TestTruncateTable` checks that a 
cached view reads no rows after the table is truncated.
   
   ### Impact
   
   Cached views and cached DataFrames over merge-on-read tables return current 
rows after a write. Uncached queries and time travel queries read the same 
instant as before.
   
   ### Risk Level
   
   low
   
   ### Documentation Update
   
   none
   
   ### Contributor's checklist
   
   - [ ] Read through [contributor's 
guide](https://hudi.apache.org/contribute/how-to-contribute)
   - [ ] Enough context is provided in the sections above
   - [ ] 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