Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion datafusion/core/src/physical_plan/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,10 @@ impl DefaultPhysicalPlanner {
LogicalPlan::TableScan(..) => {
self.create_initial_plan(input, session_state).await
}
_ => Err(DataFusionError::Plan("SubqueryAlias should only wrap TableScan".to_string()))
LogicalPlan::Filter(..) => {
self.create_initial_plan(input, session_state).await
}
_ => Err(DataFusionError::Plan("SubqueryAlias should only wrap TableScan or Filter".to_string()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we should be able to support wrapping any plan in a subquery with alias (this could also simplify some planning code).
But I got some errors trying this before.
#3927

Copy link
Member Author

@jackwener jackwener Oct 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may get your point. You hope to unify alias in the same place
Current, alias can exist two part.

  • SubqueryAlias
  • Projection Alias
    This implementation is different from Spark

Spark Subquery don't include alias.

case class Subquery(child: LogicalPlan, correlated: Boolean) extends OrderPreservingUnaryNode {
  override def output: Seq[Attribute] = child.output
  override protected def withNewChildInternal(newChild: LogicalPlan): Subquery =
    copy(child = newChild)
}

I think your thought is reasonable. We shouldn't put alias in multiple place.

We have two choices:

  • Just SubqueryAlias can contains alias
  • like spark, Subquery don't contain alias

I also agree with former, which is more suitable for the current situation of datafusion

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is just a tmp solution for #4014.

When I try to fix Integrations test, I add these code to fix it.

}
}
LogicalPlan::Limit(Limit { input, skip, fetch, .. }) => {
Expand Down