@@ -48,6 +48,7 @@ use futures::StreamExt as _;
4848use itertools:: Itertools ;
4949use object_store:: ObjectMeta ;
5050use serde:: { Deserialize , Serialize } ;
51+ use url:: Url ;
5152
5253use crate :: delta_datafusion:: schema_adapter:: DeltaSchemaAdapterFactory ;
5354use crate :: delta_datafusion:: {
@@ -60,8 +61,8 @@ use crate::kernel::{Action, Add, EagerSnapshot, Remove};
6061use crate :: operations:: write:: WriterStatsConfig ;
6162use crate :: operations:: write:: writer:: { DeltaWriter , WriterConfig } ;
6263use crate :: protocol:: { DeltaOperation , SaveMode } ;
63- use crate :: { DeltaResult , DeltaTableError , logstore :: LogStoreRef } ;
64- use crate :: { DeltaTable , ensure_table_uri } ;
64+ use crate :: table :: normalize_table_url ;
65+ use crate :: { DeltaResult , DeltaTable , DeltaTableError , logstore :: LogStoreRef } ;
6566
6667const PATH_COLUMN : & str = "__delta_rs_path" ;
6768
@@ -690,7 +691,7 @@ impl<'a> DeltaScanBuilder<'a> {
690691 . add ( files_pruned) ;
691692
692693 Ok ( DeltaScan {
693- table_uri : ensure_table_uri ( self . log_store . root_uri ( ) ) ? . as_str ( ) . into ( ) ,
694+ table_url : self . log_store . root_url ( ) . clone ( ) ,
694695 parquet_scan : DataSourceExec :: from_data_source ( file_scan_config) ,
695696 config,
696697 logical_schema,
@@ -883,23 +884,52 @@ impl TableProvider for DeltaTableProvider {
883884/// A wrapper for parquet scans
884885#[ derive( Debug ) ]
885886pub struct DeltaScan {
886- /// The URL of the ObjectStore root
887- pub table_uri : String ,
887+ /// The normalized [Url] of the ObjectStore root
888+ table_url : Url ,
888889 /// Column that contains an index that maps to the original metadata Add
889- pub config : DeltaScanConfig ,
890+ pub ( crate ) config : DeltaScanConfig ,
890891 /// The parquet scan to wrap
891- pub parquet_scan : Arc < dyn ExecutionPlan > ,
892+ pub ( crate ) parquet_scan : Arc < dyn ExecutionPlan > ,
892893 /// The schema of the table to be used when evaluating expressions
893- pub logical_schema : Arc < Schema > ,
894+ pub ( crate ) logical_schema : Arc < Schema > ,
894895 /// Metrics for scan reported via DataFusion
895- pub ( super ) metrics : ExecutionPlanMetricsSet ,
896+ metrics : ExecutionPlanMetricsSet ,
897+ }
898+
899+ impl DeltaScan {
900+ pub ( crate ) fn new (
901+ table_url : & Url ,
902+ config : DeltaScanConfig ,
903+ parquet_scan : Arc < dyn ExecutionPlan > ,
904+ logical_schema : Arc < Schema > ,
905+ ) -> Self {
906+ Self {
907+ table_url : normalize_table_url ( table_url) ,
908+ metrics : ExecutionPlanMetricsSet :: new ( ) ,
909+ config,
910+ parquet_scan,
911+ logical_schema,
912+ }
913+ }
896914}
897915
916+ #[ non_exhaustive]
898917#[ derive( Debug , Serialize , Deserialize ) ]
899918pub ( super ) struct DeltaScanWire {
900- pub table_uri : String ,
901- pub config : DeltaScanConfig ,
902- pub logical_schema : Arc < Schema > ,
919+ /// This [Url] should have already been passed through [normalize_table_url]
920+ pub ( crate ) table_url : Url ,
921+ pub ( crate ) config : DeltaScanConfig ,
922+ pub ( crate ) logical_schema : Arc < Schema > ,
923+ }
924+
925+ impl From < & DeltaScan > for DeltaScanWire {
926+ fn from ( scan : & DeltaScan ) -> Self {
927+ Self {
928+ table_url : scan. table_url . clone ( ) ,
929+ config : scan. config . clone ( ) ,
930+ logical_schema : scan. logical_schema . clone ( ) ,
931+ }
932+ }
903933}
904934
905935impl DisplayAs for DeltaScan {
@@ -940,7 +970,7 @@ impl ExecutionPlan for DeltaScan {
940970 ) ) ) ;
941971 }
942972 Ok ( Arc :: new ( DeltaScan {
943- table_uri : self . table_uri . clone ( ) ,
973+ table_url : self . table_url . clone ( ) ,
944974 config : self . config . clone ( ) ,
945975 parquet_scan : children[ 0 ] . clone ( ) ,
946976 logical_schema : self . logical_schema . clone ( ) ,
@@ -955,7 +985,7 @@ impl ExecutionPlan for DeltaScan {
955985 ) -> Result < Option < Arc < dyn ExecutionPlan > > > {
956986 if let Some ( parquet_scan) = self . parquet_scan . repartitioned ( target_partitions, config) ? {
957987 Ok ( Some ( Arc :: new ( DeltaScan {
958- table_uri : self . table_uri . clone ( ) ,
988+ table_url : self . table_url . clone ( ) ,
959989 config : self . config . clone ( ) ,
960990 parquet_scan,
961991 logical_schema : self . logical_schema . clone ( ) ,
0 commit comments