This is an automated email from the ASF dual-hosted git repository.
HyukjinKwon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark-connect-rust.git
The following commit(s) were added to refs/heads/master by this push:
new dcc0712e [SPARK-61600][FOLLOWUP][CONNECT][DOCS] Document that sort,
order_by and sort_within_partitions of no columns fail when the DataFrame runs,
in the Rust API
dcc0712e is described below
commit dcc0712ef776b410057eed941b31744b01a18a0d
Author: Hyukjin Kwon <[email protected]>
AuthorDate: Fri Nov 13 12:03:25 2026 +0900
[SPARK-61600][FOLLOWUP][CONNECT][DOCS] Document that sort, order_by and
sort_within_partitions of no columns fail when the DataFrame runs, in the Rust
API
### What changes were proposed in this pull request?
The rustdoc of `DataFrame::sort`, `order_by` and `sort_within_partitions`
now says what an empty list of columns does. It builds a sort that the server
rejects when the DataFrame runs, with `CONNECT_INVALID_PLAN.ASSERTION_FAILURE`,
as with the Scala client. PySpark's `df.sort()` and `df.sortWithinPartitions()`
raise `CANNOT_BE_EMPTY` at the call.
### Why are the changes needed?
#590 documents `Vec::<Column>::new()` as the way to pass an empty list, but
these three methods take one without an error, unlike `repartition_by_range`.
The behavior predates #590, and the signatures stay as they are. These are the
most chained methods of the API, and a `Result` would add a `?` to nearly every
caller for this edge case.
### Does this PR introduce _any_ user-facing change?
No. This is documentation only.
### How was this patch tested?
- `cargo fmt --all --check` passes.
- `cargo doc -p apache-spark-connect --no-deps` gives no warning on the
changed lines.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 5.5
This pull request and its description were written by Isaac.
Closes #603 from HyukjinKwon/SPARK-61600-followup-empty-sort.
Authored-by: Hyukjin Kwon <[email protected]>
Signed-off-by: Hyukjin Kwon <[email protected]>
---
crates/spark-connect/src/dataframe.rs | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/crates/spark-connect/src/dataframe.rs
b/crates/spark-connect/src/dataframe.rs
index ea796d1c..ecb67ab3 100644
--- a/crates/spark-connect/src/dataframe.rs
+++ b/crates/spark-connect/src/dataframe.rs
@@ -619,6 +619,10 @@ impl DataFrame {
/// Sort rows by `columns`. A sort order, of [`Column::asc`],
[`Column::desc`] and their
/// nulls variants, sorts as it says; any other column is sorted
ascending, nulls first,
/// as PySpark's `sort` sorts it.
+ ///
+ /// An empty `columns` builds a sort that the server rejects when the
DataFrame runs, with
+ /// `CONNECT_INVALID_PLAN.ASSERTION_FAILURE`, as with the Scala client.
PySpark's `df.sort()`
+ /// raises `CANNOT_BE_EMPTY` at the call instead.
pub fn sort<C: Into<Column>>(&self, columns: impl IntoIterator<Item = C>)
-> DataFrame {
let plan = LogicalPlan::Sort {
input: Arc::clone(&self.plan),
@@ -628,7 +632,8 @@ impl DataFrame {
self.with_cached_schema(plan)
}
- /// Alias for sort().
+ /// Alias for [`DataFrame::sort`]. An empty `columns` fails as it does for
+ /// [`DataFrame::sort`], when the DataFrame runs.
pub fn order_by<C: Into<Column>>(&self, columns: impl IntoIterator<Item =
C>) -> DataFrame {
self.sort(columns)
}
@@ -2325,6 +2330,8 @@ impl DataFrame {
}
/// Sort within partitions (local sort), by `columns` as
[`DataFrame::sort`] sorts by them.
+ /// An empty `columns` fails as it does for [`DataFrame::sort`], when the
DataFrame runs,
+ /// where PySpark's `df.sortWithinPartitions()` raises `CANNOT_BE_EMPTY`
at the call.
pub fn sort_within_partitions<C: Into<Column>>(
&self,
columns: impl IntoIterator<Item = C>,
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]