You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2023/09/20 20:31:36 UTC
[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #7609: Fix panic in TopK
alamb commented on code in PR #7609:
URL: https://github.com/apache/arrow-datafusion/pull/7609#discussion_r1332141464
##########
datafusion/core/src/physical_optimizer/topk_aggregation.rs:
##########
@@ -51,7 +52,7 @@ impl TopKAggregation {
if desc != order.options.descending {
return None;
}
- let group_key = aggr.group_expr().expr().first()?;
+ let group_key = aggr.group_expr().expr().iter().exactly_one().ok()?;
Review Comment:
TIL `exactly_one` 👍 makes sense to me.
Another way to write this that is more verbose but perhaps clearer might be:
```rust
if agg.group_expr().len() != 1 {
return None;
}
```
##########
datafusion/core/src/physical_optimizer/topk_aggregation.rs:
##########
@@ -51,7 +52,7 @@ impl TopKAggregation {
if desc != order.options.descending {
return None;
}
- let group_key = aggr.group_expr().expr().first()?;
+ let group_key = aggr.group_expr().expr().iter().exactly_one().ok()?;
Review Comment:
TIL `exactly_one` 👍 makes sense to me.
Another way to write this that is more verbose but perhaps clearer might be:
```rust
if agg.group_expr().len() != 1 {
return None;
}
```
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org