Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion python/pyarrow/parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,15 @@ def __new__(cls, path_or_paths=None, filesystem=None, schema=None,
metadata=None, split_row_groups=False, validate_schema=True,
filters=None, metadata_nthreads=1, read_dictionary=None,
memory_map=False, buffer_size=0, partitioning="hive",
use_legacy_dataset=True):
use_legacy_dataset=None):
if use_legacy_dataset is None:
# if a new filesystem is passed -> default to new implementation
if isinstance(filesystem, FileSystem):
use_legacy_dataset = False
# otherwise the default is still True
else:
use_legacy_dataset = True

if not use_legacy_dataset:
return _ParquetDatasetV2(path_or_paths, filesystem=filesystem,
filters=filters,
Expand Down
15 changes: 15 additions & 0 deletions python/pyarrow/tests/test_parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ def test_multiple_path_types(tempdir, use_legacy_dataset):
tm.assert_frame_equal(df, df_read)


@pytest.mark.dataset
@parametrize_legacy_dataset
@pytest.mark.parametrize("filesystem", [
None, fs.LocalFileSystem(), LocalFileSystem._get_instance()
Expand Down Expand Up @@ -4296,3 +4297,17 @@ def test_dataset_partitioning(tempdir):
with pytest.raises(ValueError):
pq.ParquetDataset(
str(root_path), partitioning=part, use_legacy_dataset=True)


@pytest.mark.dataset
def test_parquet_dataset_new_filesystem(tempdir):
# Ensure we can pass new FileSystem object to ParquetDataset
# (use new implementation automatically without specifying
# use_legacy_dataset=False)
table = pa.table({'a': [1, 2, 3]})
pq.write_table(table, tempdir / 'data.parquet')
# don't use simple LocalFileSystem (as that gets mapped to legacy one)
filesystem = fs.SubTreeFileSystem(str(tempdir), fs.LocalFileSystem())
dataset = pq.ParquetDataset('.', filesystem=filesystem)
result = dataset.read()
assert result.equals(table)