Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARROW-8318: [C++][Dataset] Construct FileSystemDataset from fragments #7073

Conversation

fsaintjacques
Copy link
Contributor

@fsaintjacques fsaintjacques commented Apr 30, 2020

  • Simplified FileSystemDataset to hold a FragmentVector. Each Fragment must be a FileFragment and is checked at FileSystemDataset::Make. Fragments are not required to use the same backing filesystem nor the same format.

  • Removed FileSystemDataset::format and FileSystemDataset::partitions.

  • Since FileInfo is not required by neither FileSystemDataset and FileSystemDatasetFactory, it is possible to create a dataset without any IO involved.

  • Re-introduced the natural behavior of creating FileFragment with their full partition expressions instead of removing the ancestors common partitions.

  • Added Expression::IsSatisfiableWith method.

  • Added missing compression cmake options to archery.

  • Ensure FileSource holds a shared_ptr pointer. This is required to refactor FileSystemDataset to support Buffer FileSource and heterogeneous FileSystems.

  • Rename type to id, following other classes.

@github-actions
Copy link

@jorisvandenbossche
Copy link
Member

Fragments are not required to use the same
backing filesystem nor the same format.

Shouldn't we require that? That seems the goal of UnionDataset to combine datasets with different formats

@bkietz bkietz self-requested a review April 30, 2020 15:57
@fsaintjacques
Copy link
Contributor Author

fsaintjacques commented Apr 30, 2020

Shouldn't we require that? That seems the goal of UnionDataset to combine datasets with different formats

Maybe, this is still enforced if you use the Factory, but you can create a FileSystemDataset with fragments from different file format.

Copy link
Member

@bkietz bkietz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good, thanks!

cpp/src/arrow/dataset/discovery.cc Outdated Show resolved Hide resolved
cpp/src/arrow/dataset/discovery.h Outdated Show resolved Hide resolved
cpp/src/arrow/dataset/file_base.cc Outdated Show resolved Hide resolved
cpp/src/arrow/dataset/filter.h Outdated Show resolved Hide resolved
python/pyarrow/_dataset.pyx Outdated Show resolved Hide resolved
cpp/src/arrow/dataset/file_base.cc Show resolved Hide resolved
fragment_partitions[ref.i] = FoldingAnd(fragment_partitions[parent.i], partition);
} else {
fragment_partitions[ref.i] = FoldingAnd(partition_expression_, partition);
for (const auto& fragment : fragments_) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow up for sub tree pruning https://issues.apache.org/jira/browse/ARROW-8658

@fsaintjacques
Copy link
Contributor Author

Due to R failure (that I didn't catch because my installation was broken and using and old version of arrow), I'll revert the FileSystemDataset::format and make sure they're homogeneous.

@jorisvandenbossche
Copy link
Member

From a user perspective, I find that also an added convenience. In Python, the FileSystemDataset.format attribute let you check the format of your dataset (instead of needing to check next(dataset.get_fragments()).format, which is not impossible of course, but I was using the format attribute in my dask branch).

@kszucs
Copy link
Member

kszucs commented May 1, 2020

Fragments are not required to use the same backing filesystem nor the same format.

This makes me wonder, why do we need FileSystemDataset and/or UnionDataset at all? Because all of the filesystem and format specific logic is implemented by the discovery objects?

It implies that we could define dataset as a vector of arbitrary fragments.

BTW this was my conclusion after my python dataset prototype, but convinced myself that a generic dataset would prevent us implementing further optimizations.

@jorisvandenbossche
Copy link
Member

Do we need FileSystemDataset, maybe not. Is it still useful, IMO yes.

As mentioned above, I personally find it convenient to know that my dataset has a single format / filesystem, and be able to easily check this format.
Now of course, it might be that this convenience is not worth it given the added complexity to the code. Or that such convenience could also be given by the wrapper languages (eg in Python we could still have a Dataset subclass for single formats)

@bkietz
Copy link
Member

bkietz commented May 1, 2020

WRT convenient single format or single file system datasets, it would be straightforward (and possibly more useful) to provide accessories for subsets, Dataset.subsets(by_format=True): { format: subset ... } Or similar. IMHO the convenience added does not justify a whole class, at least in C++. As you noted even if we remove it in C++ it could still be a convenience subclass in Python

@fsaintjacques
Copy link
Contributor Author

The ParquetFileSystemDataset will hold a parquet::Metadata for example.

* Simplified FileSystemDataset to hold a FragmentVector. Each
  Fragment must be a FileFragment and is checked at
  `FileSystemDataset::Make`.  Fragments are not required to use the same
  backing filesystem nor the same format.

* Removed `FileSystemDataset::format` and
  `FileSystemDataset::partitions`.

* Since FileInfo is not required by neither FileSystemDataset and
  FileSystemDatasetFactory, it is no possible to create a dataset
  without any IO involved.

* Re-introduced the natural behavior of creating FileFragment with their
  full partition expressions instead of removing the ancestors common
  partitions.

* Added `Expression::IsSatisfiableWith` method.

* Added missing compression cmake options to archery.

* Ensure FileSource holds a shared_ptr<FileSystem> pointer.
  This is required to refactor FileSystemDataset to support Buffer
  FileSource and heterogeneous FileSystems.

* Rename `type` to `id`, following other classes.
@fsaintjacques fsaintjacques force-pushed the ARROW-8318-fragment-in-dataset branch from 7774dd7 to d2263be Compare May 1, 2020 14:00
@fsaintjacques fsaintjacques force-pushed the ARROW-8318-fragment-in-dataset branch from 5b70f4b to 80df00e Compare May 1, 2020 14:27
@kszucs
Copy link
Member

kszucs commented May 1, 2020

I'd like elaborate a bit more on the generic dataset class regardless what kind of wrappers do we provide.

  • Do you plan to unify the filesystem classes into a single one which can contain any kind of fragments (including InMemoryFragment)?
  • Will the UnionDataset still be required?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants