Repository navigation
Commit 0abfcf5
[MINOR][PYTHON] Fix wrong expected_type in DataFrame.sort ascending type error
### What changes were proposed in this pull request?
`DataFrame.sort` / `orderBy` / `sortWithinPartitions` raise `NOT_EXPECTED_TYPE` for an invalid `ascending` argument with `expected_type` = `"Column, int or str"`. But `ascending` accepts `bool`, `int`, or `list` — never `Column` or `str`. The literal was copied from the column-argument error a few lines above in `_preapare_cols_for_sort`. This corrects it to `"bool, int or list"`.
### Why are the changes needed?
The message names types `ascending` never accepts (`Column`, `str`) and omits the ones it does (`bool`, `list`), misleading users about how to fix the call. The `ascending` parameter is documented as `bool or list`.
### Does this PR introduce _any_ user-facing change?
Yes, the error message changes.
Before:
```
[NOT_EXPECTED_TYPE] Argument `ascending` should be Column, int or str, got str.
```
After:
```
[NOT_EXPECTED_TYPE] Argument `ascending` should be bool, int or list, got str.
```
### How was this patch tested?
Added `test_sort_ascending_invalid_type` in `python/pyspark/sql/tests/test_dataframe.py` asserting the corrected `expected_type`. Verified against a released `pyspark` session: `df.sort("age", ascending="asc")` reports `bool, int or list` with the fix (previously `Column, int or str`); valid `ascending` values (`False`, `[True]`) are unaffected.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 4.8)
Closes #57522 from nikolauspschuetz/minor-sort-ascending-expected-type.
Authored-by: Nikolaus Schuetz <[email protected]>
Signed-off-by: Uros Bojanic <[email protected]>
(cherry picked from commit 1222a59)
Signed-off-by: Uros Bojanic <[email protected]>1 parent 5163a03 commit 0abfcf5
2 files changed
Lines changed: 15 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3351 | 3351 | | |
3352 | 3352 | | |
3353 | 3353 | | |
3354 | | - | |
| 3354 | + | |
3355 | 3355 | | |
3356 | 3356 | | |
3357 | 3357 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
264 | 278 | | |
265 | 279 | | |
266 | 280 | | |
| |||
0 commit comments