This is an automated email from the ASF dual-hosted git repository.

alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git


The following commit(s) were added to refs/heads/main by this push:
     new 350d4ca8a8 Update document. (#7111)
350d4ca8a8 is described below

commit 350d4ca8a895a53f51935741ee35e5b79120829c
Author: Mustafa Akur <[email protected]>
AuthorDate: Thu Jul 27 23:31:49 2023 +0300

    Update document. (#7111)
---
 datafusion/sql/src/select.rs | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/datafusion/sql/src/select.rs b/datafusion/sql/src/select.rs
index daf79e969e..59656587fa 100644
--- a/datafusion/sql/src/select.rs
+++ b/datafusion/sql/src/select.rs
@@ -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],

Reply via email to