-
Notifications
You must be signed in to change notification settings - Fork 28.3k
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
[SPARK-48307][SQL][FOLLOWUP] Eliminate the use of mutable.ArrayBuffer #47185
Conversation
@@ -140,26 +140,31 @@ case class InlineCTE( | |||
cteMap: mutable.Map[Long, CTEReferenceInfo]): LogicalPlan = { | |||
plan match { | |||
case WithCTE(child, cteDefs) => | |||
val notInlined = mutable.ArrayBuffer.empty[CTERelationDef] | |||
cteDefs.foreach { cteDef => | |||
val notInlined = cteDefs.map {cteDef => |
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 can't call flatMap
directly here?
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.
Good point :) I was confused myself somewhat.
@@ -140,26 +140,31 @@ case class InlineCTE( | |||
cteMap: mutable.Map[Long, CTEReferenceInfo]): LogicalPlan = { | |||
plan match { | |||
case WithCTE(child, cteDefs) => | |||
val notInlined = mutable.ArrayBuffer.empty[CTERelationDef] | |||
cteDefs.foreach { cteDef => | |||
val notInlined = cteDefs.map {cteDef => |
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.
nit: squash cteDefs.map -> Option
+ flatMap -> Seq
to cteDefs.flatMap -> Seq
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.
yeah sure done!
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/InlineCTE.scala
Outdated
Show resolved
Hide resolved
…mizer/InlineCTE.scala
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/InlineCTE.scala
Outdated
Show resolved
Hide resolved
…mizer/InlineCTE.scala
thanks, merging to master! |
### What changes were proposed in this pull request? We can eliminate the use of mutable.ArrayBuffer by using `flatmap`. ### Why are the changes needed? Code simplification and optimization. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Existing UT ### Was this patch authored or co-authored using generative AI tooling? No Closes apache#47185 from amaliujia/followup_cte. Lead-authored-by: Rui Wang <rui.wang@databricks.com> Co-authored-by: Kent Yao <yao@apache.org> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
### What changes were proposed in this pull request? We can eliminate the use of mutable.ArrayBuffer by using `flatmap`. ### Why are the changes needed? Code simplification and optimization. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Existing UT ### Was this patch authored or co-authored using generative AI tooling? No Closes apache#47185 from amaliujia/followup_cte. Lead-authored-by: Rui Wang <rui.wang@databricks.com> Co-authored-by: Kent Yao <yao@apache.org> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
### What changes were proposed in this pull request? We can eliminate the use of mutable.ArrayBuffer by using `flatmap`. ### Why are the changes needed? Code simplification and optimization. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Existing UT ### Was this patch authored or co-authored using generative AI tooling? No Closes apache#47185 from amaliujia/followup_cte. Lead-authored-by: Rui Wang <rui.wang@databricks.com> Co-authored-by: Kent Yao <yao@apache.org> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
What changes were proposed in this pull request?
We can eliminate the use of mutable.ArrayBuffer by using
flatmap
.Why are the changes needed?
Code simplification and optimization.
Does this PR introduce any user-facing change?
No
How was this patch tested?
Existing UT
Was this patch authored or co-authored using generative AI tooling?
No