liurenjie1024 commented on code in PR #1657:
URL: https://github.com/apache/iceberg-rust/pull/1657#discussion_r2387417043


##########
crates/iceberg/src/writer/base_writer/equality_delete_writer.rs:
##########
@@ -168,17 +168,12 @@ impl<B: FileWriterBuilder, L: LocationGenerator, F: 
FileNameGenerator> IcebergWr
                 .map(|mut res| {
                     res.content(crate::spec::DataContentType::EqualityDeletes);
                     
res.equality_ids(Some(self.equality_ids.iter().copied().collect_vec()));
-                    res.partition(
-                        self.partition_key
-                            .as_ref()
-                            .map_or(Struct::empty(), |pk| pk.data().clone()),
-                    );
-                    res.partition_spec_id(
-                        self.partition_key
-                            .as_ref()
-                            .map_or(DEFAULT_PARTITION_SPEC_ID, |pk| 
pk.spec().spec_id()),
-                    );
-                    res.build().expect("msg")
+                    if let Some(pk) = self.partition_key.as_ref() {
+                        res.partition(pk.data().clone());
+                        res.partition_spec_id(pk.spec().spec_id());
+                    }
+                    res.build()

Review Comment:
   Ditto.



##########
crates/iceberg/src/writer/base_writer/data_file_writer.rs:
##########
@@ -90,17 +93,12 @@ impl<B: FileWriterBuilder, L: LocationGenerator, F: 
FileNameGenerator> IcebergWr
                 .into_iter()
                 .map(|mut res| {
                     res.content(DataContentType::Data);
-                    res.partition(
-                        self.partition_key
-                            .as_ref()
-                            .map_or(Struct::empty(), |pk| pk.data().clone()),
-                    );
-                    res.partition_spec_id(
-                        self.partition_key
-                            .as_ref()
-                            .map_or(DEFAULT_PARTITION_SPEC_ID, |pk| 
pk.spec().spec_id()),
-                    );
-                    res.build().expect("Guaranteed to be valid")
+                    if let Some(pk) = self.partition_key.as_ref() {
+                        res.partition(pk.data().clone());
+                        res.partition_spec_id(pk.spec().spec_id());
+                    }
+                    res.build()
+                        .expect("DataFileBuilder is guaranteed to be valid")

Review Comment:
   We should not panic here.



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