Skip to content

Commit

Permalink
Update document. (#7111)
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafasrepo authored Jul 27, 2023
1 parent bd1d82f commit 350d4ca
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion datafusion/sql/src/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,28 @@ fn match_window_definitions(
Ok(())
}

/// Update group by exprs, according to functioanl dependencies
/// Update group by exprs, according to functional dependencies
/// The query below
///
/// SELECT sn, amount
/// FROM sales_global
/// GROUP BY sn
///
/// cannot be calculated, because it has a column(`amount`) which is not
/// part of group by expression.
/// However, if we know that, `sn` is determinant of `amount`. We can
/// safely, determine value of `amount` for each distinct `sn`. For these cases
/// we rewrite the query above as
///
/// SELECT sn, amount
/// FROM sales_global
/// GROUP BY sn, amount
///
/// Both queries, are functionally same. \[Because, (`sn`, `amount`) and (`sn`)
/// defines the identical groups. \]
/// This function updates group by expressions such that select expressions that are
/// not in group by expression, are added to the group by expressions if they are dependent
/// of the sub-set of group by expressions.
fn get_updated_group_by_exprs(
group_by_exprs: &[Expr],
select_exprs: &[Expr],
Expand Down

0 comments on commit 350d4ca

Please sign in to comment.