Sahitya0805 opened a new pull request, #20229:
URL: https://github.com/apache/datafusion/pull/20229
## Which issue does this PR close?
Closes #20227
## Rationale for this change
The current `Expr::sort(bool, bool)` API suffers from "boolean blindness" -
it's not clear what `sort(true, false)` means without checking the
documentation.
## What changes are included in this PR?
- Added `SortOptions` struct with fluent builder methods (`desc()`, `asc()`,
`nulls_first()`, `nulls_last()`)
- Added `Expr::sort_by()` method that accepts `SortOptions`
- Kept existing `Expr::sort()` method for backward compatibility
- Added test demonstrating both old and new APIs
## Are these changes tested?
Yes, added `repro_sort_api.rs` test that verifies:
- Old API still works correctly
- New API produces correct `Sort` struct
- Default options work as expected
## Are there any user-facing changes?
Yes, users can now use the more readable API:
```rust
// Old API (still supported)
col("foo").sort(true, false)
// New API (recommended)
col("foo").sort_by(SortOptions::new().desc().nulls_first())
```
--
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]