Zouxxyy opened a new pull request, #8232:
URL: https://github.com/apache/paimon/pull/8232

   ### Purpose
   
   For a self-referencing Replace Table As Select, e.g. `CREATE OR REPLACE 
TABLE t AS SELECT * FROM t`,
   the query previously read from the table *after* it had been truncated, 
causing all data to be lost.
   
   This PR:
   - Pins the snapshot in the query for self-referencing RTAS to the 
pre-truncation snapshot, so the
     select reads the old data instead of the truncated table.
   - Leaves relations with user-specified time travel options (e.g. `VERSION AS 
OF`) unchanged, so an
     explicitly requested snapshot is still honored.
   - Extracts `PaimonTableAsSelectHelper` from 
`PaimonReplaceTableStrategyHelper` / `PaimonStrategyHelper`
     to share `isV1SaveAsTableOverwrite`, `pinSnapshotInQuery`, and 
`rewriteToOverwrite` across Spark
     versions without duplication.
   
   ### Tests
   
   Added in `DDLTestBase`:
   - `REPLACE TABLE AS SELECT from same table preserves data` — 
self-referencing RTAS keeps the original rows.
   - `REPLACE TABLE AS SELECT with time travel reads specified snapshot` — RTAS 
with `VERSION AS OF` reads
     the requested snapshot, not the latest.


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