@@ -67,12 +67,10 @@ use datafusion_expr::{
6767 col, BinaryExpr , Expr , Extension , LogicalPlan , Operator , TableProviderFilterPushDown ,
6868 Volatility ,
6969} ;
70- use datafusion_physical_expr:: { create_physical_expr , PhysicalExpr } ;
70+ use datafusion_physical_expr:: PhysicalExpr ;
7171use datafusion_physical_plan:: filter:: FilterExec ;
72- use datafusion_physical_plan:: limit:: { GlobalLimitExec , LocalLimitExec } ;
73- use datafusion_physical_plan:: memory:: { LazyBatchGenerator , LazyMemoryExec } ;
72+ use datafusion_physical_plan:: limit:: LocalLimitExec ;
7473use datafusion_physical_plan:: metrics:: { ExecutionPlanMetricsSet , MetricBuilder , MetricsSet } ;
75- use datafusion_physical_plan:: projection:: ProjectionExec ;
7674use datafusion_physical_plan:: {
7775 DisplayAs , DisplayFormatType , ExecutionPlan , PlanProperties , SendableRecordBatchStream ,
7876 Statistics ,
@@ -85,7 +83,6 @@ use either::Either;
8583use futures:: TryStreamExt ;
8684use itertools:: Itertools ;
8785use object_store:: ObjectMeta ;
88- use parking_lot:: RwLock ;
8986use serde:: { Deserialize , Serialize } ;
9087
9188use url:: Url ;
@@ -1036,107 +1033,6 @@ impl TableProvider for DeltaTableProvider {
10361033 }
10371034}
10381035
1039- #[ derive( Debug ) ]
1040- pub struct LazyTableProvider {
1041- schema : Arc < ArrowSchema > ,
1042- batches : Vec < Arc < RwLock < dyn LazyBatchGenerator > > > ,
1043- }
1044-
1045- impl LazyTableProvider {
1046- /// Build a DeltaTableProvider
1047- pub fn try_new (
1048- schema : Arc < ArrowSchema > ,
1049- batches : Vec < Arc < RwLock < dyn LazyBatchGenerator > > > ,
1050- ) -> DeltaResult < Self > {
1051- Ok ( LazyTableProvider { schema, batches } )
1052- }
1053- }
1054-
1055- #[ async_trait]
1056- impl TableProvider for LazyTableProvider {
1057- fn as_any ( & self ) -> & dyn Any {
1058- self
1059- }
1060-
1061- fn schema ( & self ) -> Arc < ArrowSchema > {
1062- self . schema . clone ( )
1063- }
1064-
1065- fn table_type ( & self ) -> TableType {
1066- TableType :: Base
1067- }
1068-
1069- fn get_table_definition ( & self ) -> Option < & str > {
1070- None
1071- }
1072-
1073- fn get_logical_plan ( & self ) -> Option < Cow < ' _ , LogicalPlan > > {
1074- None
1075- }
1076-
1077- async fn scan (
1078- & self ,
1079- _session : & dyn Session ,
1080- projection : Option < & Vec < usize > > ,
1081- filters : & [ Expr ] ,
1082- limit : Option < usize > ,
1083- ) -> DataFusionResult < Arc < dyn ExecutionPlan > > {
1084- let mut plan: Arc < dyn ExecutionPlan > = Arc :: new ( LazyMemoryExec :: try_new (
1085- self . schema ( ) ,
1086- self . batches . clone ( ) ,
1087- ) ?) ;
1088-
1089- let df_schema: DFSchema = plan. schema ( ) . try_into ( ) ?;
1090-
1091- if let Some ( filter_expr) = conjunction ( filters. iter ( ) . cloned ( ) ) {
1092- let physical_expr =
1093- create_physical_expr ( & filter_expr, & df_schema, & ExecutionProps :: new ( ) ) ?;
1094- plan = Arc :: new ( FilterExec :: try_new ( physical_expr, plan) ?) ;
1095- }
1096-
1097- if let Some ( projection) = projection {
1098- let current_projection = ( 0 ..plan. schema ( ) . fields ( ) . len ( ) ) . collect :: < Vec < usize > > ( ) ;
1099- if projection != & current_projection {
1100- let execution_props = & ExecutionProps :: new ( ) ;
1101- let fields: DeltaResult < Vec < ( Arc < dyn PhysicalExpr > , String ) > > = projection
1102- . iter ( )
1103- . map ( |i| {
1104- let ( table_ref, field) = df_schema. qualified_field ( * i) ;
1105- create_physical_expr (
1106- & Expr :: Column ( Column :: from ( ( table_ref, field) ) ) ,
1107- & df_schema,
1108- execution_props,
1109- )
1110- . map ( |expr| ( expr, field. name ( ) . clone ( ) ) )
1111- . map_err ( DeltaTableError :: from)
1112- } )
1113- . collect ( ) ;
1114- plan = Arc :: new ( ProjectionExec :: try_new ( fields?, plan) ?) ;
1115- }
1116- }
1117-
1118- if let Some ( limit) = limit {
1119- plan = Arc :: new ( GlobalLimitExec :: new ( plan, 0 , Some ( limit) ) )
1120- } ;
1121-
1122- Ok ( plan)
1123- }
1124-
1125- fn supports_filters_pushdown (
1126- & self ,
1127- filter : & [ & Expr ] ,
1128- ) -> DataFusionResult < Vec < TableProviderFilterPushDown > > {
1129- Ok ( filter
1130- . iter ( )
1131- . map ( |_| TableProviderFilterPushDown :: Inexact )
1132- . collect ( ) )
1133- }
1134-
1135- fn statistics ( & self ) -> Option < Statistics > {
1136- None
1137- }
1138- }
1139-
11401036// TODO: this will likely also need to perform column mapping later when we support reader protocol v2
11411037/// A wrapper for parquet scans
11421038#[ derive( Debug ) ]
0 commit comments