diff --git a/python/src/filesystem.rs b/python/src/filesystem.rs index 587c004f47..697cbb39eb 100644 --- a/python/src/filesystem.rs +++ b/python/src/filesystem.rs @@ -94,7 +94,7 @@ impl DeltaFileSystemHandler { let fs = PyModule::import(py, "pyarrow.fs")?; let file_types = fs.getattr("FileType")?; - let to_file_info = |loc: String, type_: &PyAny, kwargs: HashMap<&str, i64>| { + let to_file_info = |loc: &str, type_: &PyAny, kwargs: &HashMap<&str, i64>| { fs.call_method("FileInfo", (loc, type_), Some(kwargs.into_py_dict(py))) }; @@ -116,16 +116,16 @@ impl DeltaFileSystemHandler { ("mtime_ns", meta.last_modified.timestamp_nanos()), ]); infos.push(to_file_info( - meta.location.to_string(), + meta.location.as_ref(), file_types.getattr("File")?, - kwargs, + &kwargs, )?); } Err(ObjectStoreError::NotFound { .. }) => { infos.push(to_file_info( - path.to_string(), + path.as_ref(), file_types.getattr("NotFound")?, - HashMap::new(), + &HashMap::new(), )?); } Err(err) => { @@ -134,9 +134,9 @@ impl DeltaFileSystemHandler { } } else { infos.push(to_file_info( - path.to_string(), + path.as_ref(), file_types.getattr("Directory")?, - HashMap::new(), + &HashMap::new(), )?); } } diff --git a/python/tests/test_fs.py b/python/tests/test_fs.py index 4b9dff56ad..28f50c4393 100644 --- a/python/tests/test_fs.py +++ b/python/tests/test_fs.py @@ -4,7 +4,7 @@ import pyarrow as pa import pyarrow.parquet as pq import pytest -from pyarrow.fs import S3FileSystem +from pyarrow.fs import FileType from deltalake import DeltaTable, PyDeltaTableError from deltalake.fs import DeltaStorageHandler @@ -28,6 +28,19 @@ def test_read_files(s3_localstack): assert table.shape > (0, 0) +@pytest.mark.s3 +@pytest.mark.integration +@pytest.mark.timeout(timeout=15, method="thread") +def test_read_file_info(s3_localstack): + table_path = "s3://deltars/simple" + handler = DeltaStorageHandler(table_path) + meta = handler.get_file_info( + ["part-00000-a72b1fb3-f2df-41fe-a8f0-e65b746382dd-c000.snappy.parquet"] + ) + assert len(meta) == 1 + assert meta[0].type == FileType.File + + @pytest.mark.s3 @pytest.mark.integration @pytest.mark.timeout(timeout=15, method="thread")