-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Disallow duplicated qualified field names #12608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,6 +51,7 @@ use datafusion_common::{ | |
| DFSchema, DFSchemaRef, DataFusionError, Dependency, FunctionalDependence, | ||
| FunctionalDependencies, ParamValues, Result, TableReference, UnnestOptions, | ||
| }; | ||
| use indexmap::IndexSet; | ||
|
|
||
| // backwards compatibility | ||
| use crate::display::PgJsonVisitor; | ||
|
|
@@ -3069,6 +3070,8 @@ fn calc_func_dependencies_for_aggregate( | |
| let group_by_expr_names = group_expr | ||
| .iter() | ||
| .map(|item| item.schema_name().to_string()) | ||
| .collect::<IndexSet<_>>() | ||
| .into_iter() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we directly remove duplicates from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I played around with trying to make this work and I found it was not easy -- perhaps we can do it as a follow on PR? |
||
| .collect::<Vec<_>>(); | ||
| let aggregate_func_dependencies = aggregate_functional_dependencies( | ||
| input.schema(), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,7 @@ use datafusion_common::{ | |
| DataFusionError, Result, TableReference, | ||
| }; | ||
|
|
||
| use indexmap::IndexSet; | ||
| use sqlparser::ast::{ExceptSelectItem, ExcludeSelectItem}; | ||
|
|
||
| pub use datafusion_functions_aggregate_common::order::AggregateOrderSensitivity; | ||
|
|
@@ -59,16 +60,7 @@ pub fn exprlist_to_columns(expr: &[Expr], accum: &mut HashSet<Column>) -> Result | |
| /// 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. | ||
| pub fn grouping_set_expr_count(group_expr: &[Expr]) -> Result<usize> { | ||
| if let Some(Expr::GroupingSet(grouping_set)) = group_expr.first() { | ||
| if group_expr.len() > 1 { | ||
| return plan_err!( | ||
| "Invalid group by expressions, GroupingSet must be the only expression" | ||
| ); | ||
| } | ||
| Ok(grouping_set.distinct_expr().len()) | ||
| } else { | ||
| Ok(group_expr.len()) | ||
| } | ||
| grouping_set_to_exprlist(group_expr).map(|exprs| exprs.len()) | ||
| } | ||
|
|
||
| /// The [power set] (or powerset) of a set S is the set of all subsets of S, \ | ||
|
|
@@ -260,7 +252,11 @@ pub fn grouping_set_to_exprlist(group_expr: &[Expr]) -> Result<Vec<&Expr>> { | |
| } | ||
| Ok(grouping_set.distinct_expr()) | ||
| } else { | ||
| Ok(group_expr.iter().collect()) | ||
| Ok(group_expr | ||
| .iter() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wondering if can get rid of double collection iteration? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The double iteration is used to deduplicate the values |
||
| .collect::<IndexSet<_>>() | ||
| .into_iter() | ||
| .collect()) | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -197,9 +197,9 @@ impl PlannerContext { | |
|
|
||
| /// extends the FROM schema, returning the existing one, if any | ||
| pub fn extend_outer_from_schema(&mut self, schema: &DFSchemaRef) -> Result<()> { | ||
| self.outer_from_schema = match self.outer_from_schema.as_ref() { | ||
| Some(from_schema) => Some(Arc::new(from_schema.join(schema)?)), | ||
| None => Some(Arc::clone(schema)), | ||
| match self.outer_from_schema.as_mut() { | ||
| Some(from_schema) => Arc::make_mut(from_schema).merge(schema), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TIL |
||
| None => self.outer_from_schema = Some(Arc::clone(schema)), | ||
|
Comment on lines
-200
to
+202
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @aalexandrov Can you help verify that this is correct? I am not fully following your comment here: #11456 (comment) At least in the current code merge will still have both values for |
||
| }; | ||
| Ok(()) | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this test removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should have explained that more in the description. Before it tests that calling
with_columnafter a self join without alias will fail in a certain way. After this change it will fail already at the self join. So there is no way to make it test what it testsed before and I belive the self join already has test coverage elsewhere.