JeonDaehong commented on code in PR #1164:
URL: https://github.com/apache/paimon-rust/pull/1164#discussion_r4373722912


##########
crates/paimon/src/table/kv_file_reader.rs:
##########
@@ -711,6 +764,45 @@ impl KeyValueFileReader {
                             .map(|budget| Arc::new(budget.without_prefetch()))
                     };
                     let mut file_streams: Vec<ArrowRecordBatchStream> = 
Vec::new();
+                    // One sorted run never repeats a key, so under these 
engines
+                    // every key is a lone version and needs no merge. Retract
+                    // rows are still dropped per batch below: older Rust 
writers
+                    // recorded `delete_row_count = 0` for files holding them.
+                    let mut skip_merge = skip_single_runs
+                        && input_stream_count == 1
+                        && matches!(
+                            config.merge_engine,
+                            MergeEngine::Deduplicate | MergeEngine::FirstRow
+                        );
+                    // A file written under another engine may hold several
+                    // versions of a key (the aggregation writer kept them 
before
+                    // #839), and ALTER can switch the engine afterwards.
+                    if skip_merge {
+                        'files: for run in &merge_group {
+                            for file in &run.files {
+                                // Dynamic options can override the engine but 
keep
+                                // the schema ID, so only then check the 
stored one.
+                                if file.file.schema_id == table_schema_id
+                                    && !config.merge_engine_overridden
+                                {
+                                    continue;

Review Comment:
   right, the ID match isn't enough. I dropped the flag, so it now reads the 
stored schema for every file (the schema manager caches it). if the schema file 
is missing under the read schema's ID it just merges (66abe34).
   
   added a test for your time-travel case: aggregation, ALTER to deduplicate, 
then read scan.version=1. the rewrap case is covered by the other test. both 
give [1, 1, 2] with the old ID check and [1, 2] now.
   



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