kumarUjjawal commented on code in PR #24808:
URL: https://github.com/apache/datafusion/pull/24808#discussion_r3911018379
##########
datafusion/sql/src/unparser/plan.rs:
##########
@@ -451,6 +457,92 @@ impl Unparser<'_> {
}
}
+ /// Return the alias recursion would assign when `plan` must become a
+ /// derived relation below an already rendered projection.
+ fn derived_input_alias(plan: &LogicalPlan) -> Option<&'static str> {
+ match plan {
+ LogicalPlan::Projection(_) => Some("derived_projection"),
+ LogicalPlan::Limit(_) => Some("derived_limit"),
+ LogicalPlan::Sort(_) => Some("derived_sort"),
+ LogicalPlan::Distinct(_) => Some("derived_distinct"),
+ LogicalPlan::Filter(filter) => {
+ Self::derived_input_alias(filter.input.as_ref())
+ }
+ LogicalPlan::Repartition(repartition) => {
+ Self::derived_input_alias(repartition.input.as_ref())
+ }
+ _ => None,
+ }
+ }
+
+ fn derived_input_scope<'a>(
+ plan: &'a LogicalPlan,
+ select: &SelectBuilder,
+ ) -> Option<DerivedInputScope<'a>> {
+ if select.inside_subquery_alias() {
+ return None;
+ }
+
+ match plan {
+ LogicalPlan::Projection(projection) => {
+ let alias =
Self::derived_input_alias(projection.input.as_ref())?;
Review Comment:
> Is there any part of the codebase you would recommend digging into so I
can get better at catching cases like this in the future?
Most of these comes as you spend more time with the codebase. One of the
things which I like to do is to follow the branch end to end for whatever
problem I am currently working on this gives you a pretty good path to move
along without being bogged down by all the other details present which might
not be relevant with that particular problem.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]