diff --git a/pyiceberg/io/fsspec.py b/pyiceberg/io/fsspec.py index 505b5eebbf..b7e8bd5b9a 100644 --- a/pyiceberg/io/fsspec.py +++ b/pyiceberg/io/fsspec.py @@ -519,7 +519,7 @@ def delete(self, location: str | InputFile | OutputFile) -> None: uri = urlparse(str_location) fs = self._get_fs_from_uri(uri, str_location) - fs.rm(str_location) + fs.rm_file(str_location) def _get_fs_from_uri(self, uri: "ParseResult", location: str = "") -> AbstractFileSystem: """Get a filesystem from a parsed URI, using hostname for ADLS account resolution.""" diff --git a/tests/io/test_fsspec.py b/tests/io/test_fsspec.py index 9c76e535fe..f2f67e4645 100644 --- a/tests/io/test_fsspec.py +++ b/tests/io/test_fsspec.py @@ -66,6 +66,18 @@ def test_fsspec_local_fs_can_create_path_without_parent_dir(fsspec_fileio: Fsspe pytest.fail("Failed to write to file without parent directory") +def test_fsspec_delete_does_not_expand_glob(fsspec_fileio: FsspecFileIO) -> None: + """Test delete removes only the named file when the name contains glob characters""" + with tempfile.TemporaryDirectory() as tmpdirname: + for name in ("data-1.parquet", "data-2.parquet", "data-[12].parquet"): + with open(f"{tmpdirname}/{name}", "wb") as f: + f.write(b"foo") + + fsspec_fileio.delete(f"{tmpdirname}/data-[12].parquet") + + assert sorted(os.listdir(tmpdirname)) == ["data-1.parquet", "data-2.parquet"] + + def test_fsspec_get_fs_instance_per_thread_caching(fsspec_fileio: FsspecFileIO) -> None: """Test that filesystem instances are cached per-thread by `FsspecFileIO.get_fs`""" fs_instances: list[AbstractFileSystem] = []