Jefffrey commented on issue #7024:
URL: https://github.com/apache/arrow-rs/issues/7024#issuecomment-2614621145
**arrow-rs**
```rust
#[test]
fn test123() {
let values = StringArray::from(vec![Some("a"), Some("a"), Some("b"),
None]);
let res = rank(
&values,
Some(SortOptions {
descending: false,
nulls_first: false,
}),
)
.unwrap();
dbg!(res);
}
```
Output:
```bash
arrow-rs$ cargo test -p arrow-ord --lib rank::tests::test123 -- --nocapture
Finished `test` profile [unoptimized + debuginfo] target(s) in 0.05s
Running unittests src/lib.rs
(/media/jeffrey/1tb_860evo_ssd/.cargo_target_cache/debug/deps/arrow_ord-34ffc585b0d5be26)
running 1 test
[arrow-ord/src/rank.rs:373:9] res = [
2,
2,
3,
4,
]
test rank::tests::test123 ... ok
```
**Postgres**
```sql
postgres=# WITH vals (k) AS (VALUES ('a'), ('a'), ('b'), (null))
SELECT rank() over (order by k asc nulls last) FROM vals;
rank
------
1
1
3
4
(4 rows)
```
**DuckDB**
```sql
D select rank() over (order by col0 asc nulls last) from (values ('a'),
('a'), ('b'), (null));
┌────────────────────────────────────────────┐
│ rank() OVER (ORDER BY col0 ASC NULLS LAST) │
│ int64 │
├────────────────────────────────────────────┤
│ 1 │
│ 1 │
│ 3 │
│ 4 │
└────────────────────────────────────────────┘
```
# Options
- Accept this difference and maybe enhance docs to point out this difference
in behaviour
- Change to postgres/duckdb behaviour (subtle breaking change?)
- Make configurable (API breaking change?)
--
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]