-
Notifications
You must be signed in to change notification settings - Fork 4k
ARROW-8058: [Dataset] Relax DatasetFactory discovery validation #6687
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
Closed
fsaintjacques
wants to merge
4
commits into
apache:master
from
fsaintjacques:ARROW-8058-optional-discovery-validation
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,22 +37,55 @@ | |
| namespace arrow { | ||
| namespace dataset { | ||
|
|
||
| /// \brief SourceFactory provides a way to inspect/discover a Source's expected | ||
| /// schema before materializing said Source. | ||
| struct InspectOptions { | ||
| /// See `fragments` property. | ||
| static constexpr int kInspectAllFragments = -1; | ||
|
|
||
| /// Indicate how many fragments should be inspected to infer the unified dataset | ||
| /// schema. Limiting the number of fragments accessed improves the latency of | ||
| /// the discovery process when dealing with a high number of fragments and/or | ||
| /// high latency file systems. | ||
| /// | ||
| /// The default value of `1` inspects the schema of the first (in no particular | ||
| /// order) fragment only. If the dataset has a uniform schema for all fragments, | ||
| /// this default is the optimal value. In order to inspect all fragments and | ||
| /// robustly unify their potentially varying schemas, set this option to | ||
| /// `kInspectAllFragments`. A value of `0` disables inspection of fragments | ||
| /// altogether so only the partitioning schema will be inspected. | ||
| int fragments = 1; | ||
| }; | ||
|
|
||
| struct FinishOptions { | ||
| /// Finalize the dataset with this given schema. If the schema is not | ||
| /// provided, infer the schema via the Inspect, see the `inspect_options` | ||
| /// property. | ||
| std::shared_ptr<Schema> schema = NULLPTR; | ||
|
|
||
| /// If the schema is not provided, it will be discovered by passing the | ||
| /// following options to `DatasetDiscovery::Inspect`. | ||
| InspectOptions inspect_options{}; | ||
|
|
||
| /// Indicate if the given Schema (when specified), should be validated against | ||
| /// the fragments' schemas. `inspect_options` will control how many fragments | ||
| /// are checked. | ||
| bool validate_fragments = false; | ||
fsaintjacques marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would |
||
| }; | ||
|
|
||
| /// \brief DatasetFactory provides a way to inspect/discover a Dataset's expected | ||
| /// schema before materializing said Dataset. | ||
| class ARROW_DS_EXPORT DatasetFactory { | ||
| public: | ||
| /// \brief Get the schemas of the Fragments and Partitioning. | ||
| virtual Result<std::vector<std::shared_ptr<Schema>>> InspectSchemas() = 0; | ||
| virtual Result<std::vector<std::shared_ptr<Schema>>> InspectSchemas( | ||
| InspectOptions options) = 0; | ||
|
|
||
| /// \brief Get unified schema for the resulting Dataset. | ||
| virtual Result<std::shared_ptr<Schema>> Inspect(); | ||
|
|
||
| /// \brief Create a Dataset with the given schema. | ||
| virtual Result<std::shared_ptr<Dataset>> Finish( | ||
| const std::shared_ptr<Schema>& schema) = 0; | ||
| Result<std::shared_ptr<Schema>> Inspect(InspectOptions options = {}); | ||
|
|
||
| /// \brief Create a Dataset using the inspected schema. | ||
| virtual Result<std::shared_ptr<Dataset>> Finish(); | ||
| /// \brief Create a Dataset | ||
| Result<std::shared_ptr<Dataset>> Finish(); | ||
| Result<std::shared_ptr<Dataset>> Finish(std::shared_ptr<Schema> schema); | ||
| virtual Result<std::shared_ptr<Dataset>> Finish(FinishOptions options) = 0; | ||
|
|
||
| /// \brief Optional root partition for the resulting Dataset. | ||
| const std::shared_ptr<Expression>& root_partition() const { return root_partition_; } | ||
|
|
@@ -82,16 +115,15 @@ class ARROW_DS_EXPORT UnionDatasetFactory : public DatasetFactory { | |
| } | ||
|
|
||
| /// \brief Get the schemas of the Datasets. | ||
| Result<std::vector<std::shared_ptr<Schema>>> InspectSchemas() override; | ||
|
|
||
| /// \brief Get unified schema for the resulting Dataset. | ||
| Result<std::shared_ptr<Schema>> Inspect() override; | ||
|
|
||
| /// \brief Create a Dataset with the given schema. | ||
| Result<std::shared_ptr<Dataset>> Finish(const std::shared_ptr<Schema>& schema) override; | ||
| /// | ||
| /// Instead of applying options globally, it applies at each child factory. | ||
| /// This will not respect `options.fragments` exactly, but will respect the | ||
| /// spirit of peeking the first fragments or all of them. | ||
| Result<std::vector<std::shared_ptr<Schema>>> InspectSchemas( | ||
| InspectOptions options) override; | ||
|
|
||
| /// \brief Create a Dataset using the inspected schema. | ||
| Result<std::shared_ptr<Dataset>> Finish() override; | ||
| /// \brief Create a Dataset. | ||
| Result<std::shared_ptr<Dataset>> Finish(FinishOptions options) override; | ||
|
|
||
| protected: | ||
| explicit UnionDatasetFactory(std::vector<std::shared_ptr<DatasetFactory>> factories); | ||
|
|
@@ -131,7 +163,7 @@ struct FileSystemFactoryOptions { | |
| // in a serial and single threaded fashion. Disabling this feature will skip the | ||
| // IO, but unsupported files may be present in the Dataset | ||
| // (resulting in an error at scan time). | ||
| bool exclude_invalid_files = true; | ||
| bool exclude_invalid_files = false; | ||
|
|
||
| // Files matching one of the following prefix will be ignored by the | ||
| // discovery process. This is matched to the basename of a path. | ||
|
|
@@ -180,9 +212,10 @@ class ARROW_DS_EXPORT FileSystemDatasetFactory : public DatasetFactory { | |
| std::shared_ptr<fs::FileSystem> filesystem, fs::FileSelector selector, | ||
| std::shared_ptr<FileFormat> format, FileSystemFactoryOptions options); | ||
|
|
||
| Result<std::vector<std::shared_ptr<Schema>>> InspectSchemas() override; | ||
| Result<std::vector<std::shared_ptr<Schema>>> InspectSchemas( | ||
| InspectOptions options) override; | ||
|
|
||
| Result<std::shared_ptr<Dataset>> Finish(const std::shared_ptr<Schema>& schema) override; | ||
| Result<std::shared_ptr<Dataset>> Finish(FinishOptions options) override; | ||
|
|
||
| protected: | ||
| FileSystemDatasetFactory(std::shared_ptr<fs::FileSystem> filesystem, | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.