-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
GH-26818: [C++][Python] Preserve order when writing dataset multi-threaded #44470
base: main
Are you sure you want to change the base?
Conversation
|
9ca8c76
to
28cb588
Compare
This pull request seems to functionally overlap with this one. Some changes are almost exactly the same. Ordering of data is kept in threaded execution with use of batch index. Can you check whether it fixes your use case also? |
28cb588
to
0377ef9
Compare
@@ -103,8 +103,8 @@ class ARROW_ACERO_EXPORT SourceNodeOptions : public ExecNodeOptions { | |||
std::shared_ptr<Schema> output_schema; | |||
/// \brief an asynchronous stream of batches ending with std::nullopt | |||
std::function<Future<std::optional<ExecBatch>>()> generator; | |||
|
|||
Ordering ordering = Ordering::Unordered(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constructor has a default value for ordering and initializes ordering
with the value given to the constructor. No point for another default value here, I think.
2776b34
to
6024066
Compare
acero::ConsumingSinkNodeOptions{ | ||
std::move(consumer), | ||
{}, | ||
/*sequence_output=*/write_options.preserve_order})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TeeNode needs the same treatment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, looks like this requires some refactoring, since TeeNode
is not used for writing datasets I'd leave this to a separate PR.
Since you are fixing dataset write ordering I think this check never fires. It should be moved to InsertBatch. |
6024066
to
697c378
Compare
@gitmodimo I think that refactoring should be done in a separate PR keeping this PR focused on fixing the issue. |
Rationale for this change
The order of rows in a dataset might be important for users and should be preserved when writing to a filesystem. With multi-threaded write, the order is currently not guaranteed,
What changes are included in this PR?
Preserving the dataset order of rows requires the
SourceNode
to useImplicitOrdering
(this gives exec batches an index), and theConsumingSinkNode
to sequence exec batches (preserve order of batches by their index).User-facing changes:
preserve_order
toFileSystemDatasetWriteOptions
Dev-facing changes:
ordering
toSourceNodeOptions
implicit_ordering
toScanNodeOptions
Default behaviour is current behaviour.
Are these changes tested?
Unit tests have been added,
Are there any user-facing changes?
Users can set
FileSystemDatasetWriteOptions.preserve_order = true
(C++) /arrow.dataset.write_dataset(..., preserve_order=True)
(Python).