Skip to content

Commit

Permalink
ARROW-18123: [Python] Fix writing files with multi-byte characters in…
Browse files Browse the repository at this point in the history
… file name (apache#14764)

Will close [ARROW-18123](https://issues.apache.org/jira/browse/ARROW-18123)

Authored-by: Miles Granger <miles59923@gmail.com>
Signed-off-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
  • Loading branch information
milesgranger authored Dec 7, 2022
1 parent 17b90d1 commit 26a426f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion python/pyarrow/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ def _resolve_filesystem_and_path(
# neither an URI nor a locally existing path, so assume that
# local path was given and propagate a nicer file not found error
# instead of a more confusing scheme parsing error
if "empty scheme" not in str(e):
if "empty scheme" not in str(e) \
and "Cannot parse URI" not in str(e):
raise
else:
path = filesystem.normalize_path(path)
Expand Down
15 changes: 10 additions & 5 deletions python/pyarrow/tests/parquet/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,21 +289,26 @@ def test_fspath(tempdir, use_legacy_dataset):
@pytest.mark.parametrize("filesystem", [
None, fs.LocalFileSystem(), LocalFileSystem._get_instance()
])
def test_relative_paths(tempdir, use_legacy_dataset, filesystem):
@pytest.mark.parametrize("name", ("data.parquet", "例.parquet"))
def test_relative_paths(tempdir, use_legacy_dataset, filesystem, name):
# reading and writing from relative paths
table = pa.table({"a": [1, 2, 3]})
path = tempdir / name

# reading
pq.write_table(table, str(tempdir / "data.parquet"))
pq.write_table(table, str(path))
with util.change_cwd(tempdir):
result = pq.read_table("data.parquet", filesystem=filesystem,
result = pq.read_table(name, filesystem=filesystem,
use_legacy_dataset=use_legacy_dataset)
assert result.equals(table)

path.unlink()
assert not path.exists()

# writing
with util.change_cwd(tempdir):
pq.write_table(table, "data2.parquet", filesystem=filesystem)
result = pq.read_table(tempdir / "data2.parquet")
pq.write_table(table, name, filesystem=filesystem)
result = pq.read_table(path)
assert result.equals(table)


Expand Down

0 comments on commit 26a426f

Please sign in to comment.