adriangb commented on code in PR #18233:
URL: https://github.com/apache/datafusion/pull/18233#discussion_r2453404767
##########
datafusion/datasource/src/memory.rs:
##########
@@ -192,12 +193,27 @@ impl DataSource for MemorySourceConfig {
SchedulingType::Cooperative
}
- fn statistics(&self) -> Result<Statistics> {
- Ok(common::compute_record_batch_statistics(
- &self.partitions,
- &self.schema,
- self.projection.clone(),
- ))
+ fn partition_statistics(&self, partition: Option<usize>) ->
Result<Statistics> {
+ if let Some(partition) = partition {
+ // Compute statistics for a specific partition
+ if let Some(batches) = self.partitions.get(partition) {
+ Ok(common::compute_record_batch_statistics(
+ from_ref(&batches),
+ &self.schema,
+ self.projection.clone(),
+ ))
+ } else {
+ // Invalid partition index
+ Ok(Statistics::new_unknown(&self.projected_schema))
+ }
+ } else {
+ // Compute statistics across all partitions
+ Ok(common::compute_record_batch_statistics(
+ &self.partitions,
+ &self.schema,
+ self.projection.clone(),
+ ))
+ }
}
Review Comment:
Previously unimplemented because only FileScanConfig was handled via
downcast matching.
--
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]