comphead commented on code in PR #1443:
URL: https://github.com/apache/datafusion-comet/pull/1443#discussion_r1970312264
##########
native/core/src/execution/planner.rs:
##########
@@ -176,6 +173,61 @@ impl PhysicalPlanner {
}
}
+ /// get DataFusion PartitionedFiles from a Spark FilePartition
+ fn get_partitioned_files(
+ &self,
+ partition: &SparkFilePartition,
+ ) -> Result<Vec<PartitionedFile>, ExecutionError> {
+ let mut files = Vec::with_capacity(partition.partitioned_file.len());
+ partition.partitioned_file.iter().try_for_each(|file| {
+ assert!(file.start + file.length <= file.file_size);
+
+ let mut partitioned_file = PartitionedFile::new_with_range(
+ String::new(), // Dummy file path.
+ file.file_size as u64,
+ file.start,
+ file.start + file.length,
+ );
+
+ // Spark sends the path over as URL-encoded, parse that first.
+ let url = Url::parse(file.file_path.as_ref()).unwrap();
+ // Convert that to a Path object to use in the PartitionedFile.
+ let path = Path::from_url_path(url.path()).unwrap();
+ partitioned_file.object_meta.location = path;
+
+ // Process partition values
+ // Create an empty input schema for partition values because they
are all literals.
+ let empty_schema = Arc::new(Schema::empty());
+ let partition_values: Result<Vec<_>, _> = file
+ .partition_values
+ .iter()
+ .map(|partition_value| {
+ let literal =
+ self.create_expr(partition_value,
Arc::<Schema>::clone(&empty_schema))?;
+ literal
+ .as_any()
+ .downcast_ref::<DataFusionLiteral>()
+ .ok_or_else(|| {
+ ExecutionError::GeneralError(
+ "Expected literal of partition
value".to_string(),
+ )
+ })
+ .map(|literal| literal.value().clone())
+ })
+ .collect();
+ let partition_values = partition_values?;
+
+ partitioned_file.partition_values = partition_values;
+
+ files.push(partitioned_file);
+ Ok::<(), ExecutionError>(())
+ })?;
+
+ // file_groups.push(files);
+ // Ok::<(), ExecutionError>(())
Review Comment:
```suggestion
```
--
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]