anoopj commented on code in PR #2952:
URL: https://github.com/apache/iceberg-rust/pull/2952#discussion_r3713655216


##########
crates/iceberg/src/scan/mod.rs:
##########
@@ -996,6 +996,84 @@ pub mod tests {
             manifest_list_write.close().await.unwrap();
         }
 
+        /// Writes a v3 data manifest with a manifest-level `first_row_id` of 
0,
+        /// so live entries inherit a per-file `first_row_id` on read. 
Upgrades the
+        /// table to v3 first, so the manifest list is read as v3.
+        pub async fn setup_v3_manifest_files(&mut self) {
+            let metadata = TableMetadataBuilder::new_from_metadata(
+                self.table.metadata().clone(),
+                self.table.metadata_location().map(str::to_string),
+            )
+            .upgrade_format_version(FormatVersion::V3)
+            .unwrap()
+            .build()
+            .unwrap()
+            .metadata;
+            self.table = Table::builder()
+                .metadata(metadata)
+                .identifier(self.table.identifier().clone())
+                .file_io(self.table.file_io().clone())
+                
.metadata_location(self.table.metadata_location().unwrap().to_string())
+                .runtime(test_runtime())
+                .build()
+                .unwrap();
+
+            let current_snapshot = 
self.table.metadata().current_snapshot().unwrap();
+            let current_schema = 
current_snapshot.schema(self.table.metadata()).unwrap();
+            let current_partition_spec = 
self.table.metadata().default_partition_spec();
+
+            let parquet_file_size = self.write_parquet_data_files();
+
+            let mut writer = ManifestWriterBuilder::new(
+                self.next_manifest_file(),
+                Some(current_snapshot.snapshot_id()),
+                current_schema.clone(),
+                current_partition_spec.as_ref().clone(),
+            )
+            .build_v3_data();
+            writer
+                .add_entry(
+                    ManifestEntry::builder()
+                        .status(ManifestStatus::Added)
+                        .data_file(
+                            DataFileBuilder::default()
+                                .partition_spec_id(0)
+                                .content(DataContentType::Data)
+                                .file_path(format!("{}/1.parquet", 
&self.table_location))
+                                .file_format(DataFileFormat::Parquet)
+                                .file_size_in_bytes(parquet_file_size)
+                                .record_count(1)
+                                
.partition(Struct::from_iter([Some(Literal::long(100))]))
+                                .key_metadata(None)
+                                .build()
+                                .unwrap(),
+                        )
+                        .build(),
+                )
+                .unwrap();
+            let data_file_manifest = 
writer.write_manifest_file().await.unwrap();
+
+            let manifest_list_writer = self
+                .table
+                .file_io()
+                .new_output(current_snapshot.manifest_list())
+                .unwrap()
+                .writer()
+                .await
+                .unwrap();
+            let mut manifest_list_write = ManifestListWriter::v3(
+                manifest_list_writer,
+                current_snapshot.snapshot_id(),
+                current_snapshot.parent_snapshot_id(),
+                current_snapshot.sequence_number(),
+                Some(0),

Review Comment:
   That is a good point and `42` is a good choice. :) Fixed the assertion



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to