QuakeWang commented on code in PR #379:
URL: https://github.com/apache/paimon-rust/pull/379#discussion_r3400102401


##########
crates/paimon/src/table/mod.rs:
##########
@@ -184,7 +199,54 @@ impl Table {
             schema: self.schema.copy_with_options(extra),
             schema_manager: self.schema_manager.clone(),
             rest_env: self.rest_env.clone(),
+            time_traveled: self.time_traveled,

Review Comment:
   `copy_with_options` keeps `time_traveled` and the current schema, but clears 
`travel_snapshot`. If this is called on a table already returned by 
`copy_with_time_travel`, the result can keep the old snapshot schema while 
resolving a different snapshot later during scan.
   
   That can produce a mismatched table state: historical schema from one 
snapshot, scan snapshot from another selector/latest. Please either make this 
transition impossible, reset back to the base/latest schema, or re-resolve time 
travel when options change.



##########
crates/paimon/src/table/write_builder.rs:
##########
@@ -80,6 +80,16 @@ impl<'a> WriteBuilder<'a> {
     /// For primary-key tables, sequence numbers are lazily scanned per 
partition
     /// when the first writer for that partition is created.
     pub fn new_write(&self) -> crate::Result<TableWrite> {
+        // A time-travelled table copy carries a historical schema; writing
+        // through it would silently produce data shaped like the old schema.
+        // Java avoids this structurally (write paths use 
copyWithoutTimeTravel);
+        // here the same table copy can serve both reads and writes, so reject
+        // explicitly. Commit-only flows (new_commit) stay untouched.
+        if self.table.is_time_traveled() {

Review Comment:
   This guard is too narrow. `is_time_traveled()` is only true when the 
resolved snapshot uses a different schema id, so writes are still allowed when 
`scan.version` / `scan.timestamp-millis` resolves to a snapshot with the same 
schema id.
   
   That leaves ordinary `INSERT` able to write the latest table while the 
session is reading a historical snapshot. A minimal case is: create two 
snapshots without schema evolution, `SET 'paimon.scan.version' = '1'`, then 
`INSERT INTO ...` succeeds.
   
   Please reject writes whenever the table options contain a time-travel 
selector, not only when the table switched to a historical schema.



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