You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/10/06 06:38:04 UTC
[GitHub] [arrow-datafusion] xudong963 commented on a change in pull request #1067: fix subquery alias
xudong963 commented on a change in pull request #1067:
URL: https://github.com/apache/arrow-datafusion/pull/1067#discussion_r722927932
##########
File path: datafusion/src/sql/planner.rs
##########
@@ -522,21 +521,43 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
name
))),
}?,
- columns_alias,
+ alias,
)
}
TableFactor::Derived {
subquery, alias, ..
- } => (
- self.query_to_plan_with_alias(
+ } => {
+ // if alias is None, return Err
+ if alias.is_none() {
+ return Err(DataFusionError::Plan(
+ "subquery in FROM must have an alias".parse().unwrap(),
+ ));
+ }
+ let logical_plan = self.query_to_plan_with_alias(
subquery,
alias.as_ref().map(|a| a.name.value.to_string()),
ctes,
- )?,
- alias.clone().map(|x| x.columns),
- ),
+ )?;
+ let schema = logical_plan.schema();
Review comment:
> My guess is the projection won't work if the schema is still referencing the original qualifier, i.e. projection asked for `b.id`, but the input plan schema only has `customer.id`, resulting in runtime error.
yep! cc @alamb
--
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