@@ -14,7 +14,6 @@ use crate::{DeltaResult, Error, FileMeta, FileSlice, FileSystemClient};
1414pub struct ObjectStoreFileSystemClient < E : TaskExecutor > {
1515 inner : Arc < DynObjectStore > ,
1616 has_ordered_listing : bool ,
17- table_root : Path ,
1817 task_executor : Arc < E > ,
1918 readahead : usize ,
2019}
@@ -23,13 +22,11 @@ impl<E: TaskExecutor> ObjectStoreFileSystemClient<E> {
2322 pub ( crate ) fn new (
2423 store : Arc < DynObjectStore > ,
2524 has_ordered_listing : bool ,
26- table_root : Path ,
2725 task_executor : Arc < E > ,
2826 ) -> Self {
2927 Self {
3028 inner : store,
3129 has_ordered_listing,
32- table_root,
3330 task_executor,
3431 readahead : 10 ,
3532 }
@@ -49,8 +46,14 @@ impl<E: TaskExecutor> FileSystemClient for ObjectStoreFileSystemClient<E> {
4946 ) -> DeltaResult < Box < dyn Iterator < Item = DeltaResult < FileMeta > > > > {
5047 let url = path. clone ( ) ;
5148 let offset = Path :: from ( path. path ( ) ) ;
52- // TODO properly handle table prefix
53- let prefix = self . table_root . child ( "_delta_log" ) ;
49+ let parts = offset. parts ( ) . collect_vec ( ) ;
50+ if parts. len ( ) == 0 {
51+ return Err ( Error :: generic ( format ! (
52+ "Offset path must not be a root directory. Got: '{}'" ,
53+ url. as_str( )
54+ ) ) ) ;
55+ }
56+ let prefix = Path :: from_iter ( parts[ ..parts. len ( ) - 1 ] . iter ( ) . cloned ( ) ) ;
5457
5558 let store = self . inner . clone ( ) ;
5659
@@ -192,11 +195,9 @@ mod tests {
192195 let mut url = Url :: from_directory_path ( tmp. path ( ) ) . unwrap ( ) ;
193196
194197 let store = Arc :: new ( LocalFileSystem :: new ( ) ) ;
195- let prefix = Path :: from ( url. path ( ) ) ;
196198 let client = ObjectStoreFileSystemClient :: new (
197199 store,
198200 false , // don't have ordered listing
199- prefix,
200201 Arc :: new ( TokioBackgroundExecutor :: new ( ) ) ,
201202 ) ;
202203
@@ -229,11 +230,10 @@ mod tests {
229230 store. put ( & name, data. clone ( ) . into ( ) ) . await . unwrap ( ) ;
230231
231232 let table_root = Url :: parse ( "memory:///" ) . expect ( "valid url" ) ;
232- let prefix = Path :: from_url_path ( table_root. path ( ) ) . expect ( "Couldn't get path" ) ;
233- let engine = DefaultEngine :: new ( store, prefix, Arc :: new ( TokioBackgroundExecutor :: new ( ) ) ) ;
233+ let engine = DefaultEngine :: new ( store, Arc :: new ( TokioBackgroundExecutor :: new ( ) ) ) ;
234234 let files: Vec < _ > = engine
235235 . get_file_system_client ( )
236- . list_from ( & table_root)
236+ . list_from ( & table_root. join ( "_delta_log/0" ) . unwrap ( ) )
237237 . unwrap ( )
238238 . try_collect ( )
239239 . unwrap ( ) ;
@@ -260,11 +260,12 @@ mod tests {
260260
261261 let url = Url :: from_directory_path ( tmp. path ( ) ) . unwrap ( ) ;
262262 let store = Arc :: new ( LocalFileSystem :: new ( ) ) ;
263- let prefix = Path :: from_url_path ( url. path ( ) ) . expect ( "Couldn't get path" ) ;
264- let engine = DefaultEngine :: new ( store, prefix, Arc :: new ( TokioBackgroundExecutor :: new ( ) ) ) ;
263+ let engine = DefaultEngine :: new ( store, Arc :: new ( TokioBackgroundExecutor :: new ( ) ) ) ;
265264 let client = engine. get_file_system_client ( ) ;
266265
267- let files = client. list_from ( & Url :: parse ( "file://" ) . unwrap ( ) ) . unwrap ( ) ;
266+ let files = client
267+ . list_from ( & url. join ( "_delta_log/0" ) . unwrap ( ) )
268+ . unwrap ( ) ;
268269 let mut len = 0 ;
269270 for ( file, expected) in files. zip ( expected_names. iter ( ) ) {
270271 assert ! (
0 commit comments