MCPcopy Create free account
hub / github.com/apache/datafusion / grouping_set_expr_count

Function grouping_set_expr_count

datafusion/expr/src/utils.rs:55–67  ·  view source on GitHub ↗

Count the number of distinct exprs in a list of group by expressions. If the first element is a `GroupingSet` expression then it must be the only expr.

(group_expr: &[Expr])

Source from the content-addressed store, hash-verified

53/// Count the number of distinct exprs in a list of group by expressions. If the
54/// first element is a `GroupingSet` expression then it must be the only expr.
55pub fn grouping_set_expr_count(group_expr: &[Expr]) -> Result<usize> {
56 if let Some(Expr::GroupingSet(grouping_set)) = group_expr.first() {
57 if group_expr.len() > 1 {
58 return plan_err!(
59 "Invalid group by expressions, GroupingSet must be the only expression"
60 );
61 }
62 // Groupings sets have an additional integral column for the grouping id
63 Ok(grouping_set.distinct_expr().len() + 1)
64 } else {
65 grouping_set_to_exprlist(group_expr).map(|exprs| exprs.len())
66 }
67}
68
69/// Internal helper that generates indices for powerset subsets using bitset iteration.
70/// Returns an iterator of index vectors, where each vector contains the indices

Callers 2

try_new_with_schemaMethod · 0.85
group_expr_lenMethod · 0.85

Calls 5

grouping_set_to_exprlistFunction · 0.85
distinct_exprMethod · 0.80
firstMethod · 0.45
lenMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…