Skip to content
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

Closed
wants to merge 6 commits into from

Conversation

amaliujia
Copy link
Contributor

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

@amaliujia
Copy link
Contributor Author

@cloud-fan

@github-actions github-actions bot added the SQL label Jul 2, 2024
@@ -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 =>
Copy link
Contributor

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?

Copy link
Contributor Author

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 =>
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah sure done!

@cloud-fan
Copy link
Contributor

thanks, merging to master!

@cloud-fan cloud-fan closed this in dab708e Jul 9, 2024
ericm-db pushed a commit to ericm-db/spark that referenced this pull request Jul 10, 2024
### 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>
jingz-db pushed a commit to jingz-db/spark that referenced this pull request Jul 22, 2024
### 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>
attilapiros pushed a commit to attilapiros/spark that referenced this pull request Oct 4, 2024
### 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants