zhuqi-lucas commented on code in PR #14644:
URL: https://github.com/apache/datafusion/pull/14644#discussion_r1957058065
##########
datafusion/physical-plan/src/sorts/sort.rs:
##########
@@ -641,7 +702,15 @@ pub fn sort_batch(
lexsort_to_indices(&sort_columns, fetch)?
};
- let columns = take_arrays(batch.columns(), &indices, None)?;
+ let mut columns = take_arrays(batch.columns(), &indices, None)?;
+
+ // The columns may be larger than the unsorted columns in `batch`
especially for variable length
+ // data types due to exponential growth when building the sort columns. We
shrink the columns
+ // to prevent memory reservation failures, as well as excessive memory
allocation when running
+ // merges in `SortPreservingMergeStream`.
+ columns.iter_mut().for_each(|c| {
Review Comment:
It makes sense.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]