File tree Expand file tree Collapse file tree
datafusion-federation/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11use async_stream:: stream;
22use datafusion:: arrow:: datatypes:: SchemaRef ;
3+ use datafusion:: common:: Statistics ;
34use datafusion:: error:: { DataFusionError , Result } ;
45use datafusion:: execution:: { SendableRecordBatchStream , TaskContext } ;
56use datafusion:: physical_plan:: stream:: RecordBatchStreamAdapter ;
@@ -113,4 +114,8 @@ impl ExecutionPlan for SchemaCastScanExec {
113114 } ,
114115 ) ) )
115116 }
117+
118+ fn partition_statistics ( & self , partition : Option < usize > ) -> Result < Statistics > {
119+ self . input . partition_statistics ( partition)
120+ }
116121}
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ use async_trait::async_trait;
22use core:: fmt;
33use datafusion:: {
44 arrow:: datatypes:: SchemaRef ,
5+ common:: Statistics ,
56 error:: Result ,
67 logical_expr:: LogicalPlan ,
78 physical_plan:: SendableRecordBatchStream ,
@@ -43,6 +44,18 @@ pub trait SQLExecutor: Sync + Send {
4344 /// Execute a SQL query
4445 fn execute ( & self , query : & str , schema : SchemaRef ) -> Result < SendableRecordBatchStream > ;
4546
47+ /// Returns statistics for this `SQLExecutor` node. If statistics are not available, it should
48+ /// return [`Statistics::new_unknown`] (the default), not an error. See the `ExecutionPlan`
49+ /// trait.
50+ fn partition_statistics (
51+ & self ,
52+ _partition : Option < usize > ,
53+ _query : & str ,
54+ schema : SchemaRef ,
55+ ) -> Result < Statistics > {
56+ Ok ( Statistics :: new_unknown ( & schema) )
57+ }
58+
4659 /// Returns the tables provided by the remote
4760 async fn table_names ( & self ) -> Result < Vec < String > > ;
4861
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ use async_trait::async_trait;
1212use datafusion:: {
1313 arrow:: datatypes:: { Schema , SchemaRef } ,
1414 common:: tree_node:: { Transformed , TreeNode } ,
15+ common:: Statistics ,
1516 error:: { DataFusionError , Result } ,
1617 execution:: { context:: SessionState , TaskContext } ,
1718 logical_expr:: { Extension , LogicalPlan } ,
@@ -343,6 +344,11 @@ impl ExecutionPlan for VirtualExecutionPlan {
343344 fn properties ( & self ) -> & PlanProperties {
344345 & self . props
345346 }
347+
348+ fn partition_statistics ( & self , partition : Option < usize > ) -> Result < Statistics > {
349+ self . executor
350+ . partition_statistics ( partition, & self . final_sql ( ) ?, self . schema ( ) )
351+ }
346352}
347353
348354#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments