CTTY commented on code in PR #1625:
URL: https://github.com/apache/iceberg-rust/pull/1625#discussion_r2299291559


##########
crates/iceberg/src/writer/file_writer/location_generator.rs:
##########
@@ -21,14 +21,24 @@ use std::sync::Arc;
 use std::sync::atomic::AtomicU64;
 
 use crate::Result;
-use crate::spec::{DataFileFormat, TableMetadata};
+use crate::spec::{DataFileFormat, PartitionKey, TableMetadata, 
partition_key_is_none};
 
 /// `LocationGenerator` used to generate the location of data file.
 pub trait LocationGenerator: Clone + Send + 'static {
-    /// Generate an absolute path for the given file name.
-    /// e.g.
-    /// For file name "part-00000.parquet", the generated location maybe 
"/table/data/part-00000.parquet"
-    fn generate_location(&self, file_name: &str) -> String;
+    /// Generate an absolute path for the given file name that includes the 
partition path.
+    ///
+    /// # Arguments
+    ///
+    /// * `partition_key` - The partition key of the file. If None, generate a 
non-partitioned path.
+    /// * `file_name` - The name of the file
+    ///
+    /// # Returns
+    ///
+    /// An absolute path that includes the partition path, e.g.,
+    /// "/table/data/id=1/name=alice/part-00000.parquet"
+    /// or non-partitioned path:
+    /// "/table/data/part-00000.parquet"
+    fn generate_location(&self, partition_key: Option<PartitionKey>, 
file_name: &str) -> String;

Review Comment:
   I think having two methods like `generate_location` and 
`generate_location_with_partition` can be clunky to use, this basically means 
all writers that support partitioned writing always need to have:
   ```
   match partition_key.is_none() // or some other conditions to determine if we 
are writing to a partitioned table
      Some => generate_location_with_partition()
      None => generate_location()
   ```
   
   Having a new API is also cool and I don't have a strong opinion on this, 
please let me know what you think!
   



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