alamb commented on a change in pull request #8751:
URL: https://github.com/apache/arrow/pull/8751#discussion_r530466598
##########
File path: rust/datafusion/src/optimizer/projection_push_down.rs
##########
@@ -114,6 +114,10 @@ fn optimize_plan(
has_projection: bool,
) -> Result<LogicalPlan> {
match plan {
+ LogicalPlan::Alias(plan, alias) => {
+ let new_input = optimize_plan(optimizer, &plan, &required_columns,
true)?;
+ Ok(LogicalPlan::Alias(Box::new(new_input), alias.to_owned()))
Review comment:
I suspect this code will eventually need a translation layer (from
expressions in the sub plan to expressions in the outer query) -- I left more
thoughts above
##########
File path: rust/datafusion/src/logical_plan/plan.rs
##########
@@ -114,6 +114,8 @@ pub enum LogicalPlan {
/// The output schema, containing fields from the left and right inputs
schema: SchemaRef,
},
+ /// Aliased relation
+ Alias(Box<LogicalPlan>, String),
Review comment:
@andygrove -- this is very cool. Thank you.
I think that planning Joins in general is going to need the notion that any
reference to a column has both a `column_name `(which DataFusion already
supports) as well as a `relation_name` (aka what table it comes from) which
DataFusion doesn't currently support.
I see below that we are starting to encode this notion using strings like
`"orders.order_id"`. I think we should consider (at least eventually) encoding
the relation name in Expr::Column itself -- aka here:
https://github.com/apache/arrow/blob/master/rust/datafusion/src/logical_plan/expr.rs#L59
Doing so means we will have to add code in the sql parser to translate
references from `order_id` to `orders.order_id` but I think we are going to
need to do that anyways. Without this ability to distinguish between column
references from different relations, it will be tough to make joins work I
think.
I didn't quite follow the need for this `Alias` type of plan node -- I think
perhaps all the sources (e.g. `TableScan`, etc) could have a relation name.
Then the expressions should be unambiguous
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]