You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/07/30 18:07:23 UTC
[GitHub] [spark] jiaji-wu opened a new pull request, #37348: [SPARK-39854][SQL] replaceWithAliases should keep the original children for Generate
jiaji-wu opened a new pull request, #37348:
URL: https://github.com/apache/spark/pull/37348
<!--
Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
4. Be sure to keep the PR description updated to reflect all changes.
5. Please write your PR title to summarize what this PR proposes.
6. If possible, provide a concise example to reproduce the issue for a faster review.
7. If you want to add a new configuration, please read the guideline first for naming configurations in
'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
8. If you want to add or modify an error type or message, please read the guideline first in
'core/src/main/resources/error/README.md'.
-->
### What changes were proposed in this pull request?
<!--
Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue.
If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
2. If you fix some SQL features, you can provide some references of other DBMSes.
3. If there is design documentation, please add the link.
4. If there is a discussion in the mailing list, please add the link.
-->
The current implementation of the `replaceWithAliases` method in `NestedColumnAliasing` replaces the children of the current plan with mapped aliases. When the current plan is a `Generate` -- which keeps a set of indices `unrequiredChildIndex` for unsed child outputs -- and if the replaced child happens to be in this set, because the `unrequiredChildIndex` is not updated for this `Generate` plan, the original `unrequiredChildIndex` will point to the new children, leading to exceptions/errors.
### Why are the changes needed?
<!--
Please clarify why the changes are needed. For instance,
1. If you propose a new API, clarify the use case for a new API.
2. If you fix a bug, you can clarify why it is a bug.
-->
See the description above.
### Does this PR introduce _any_ user-facing change?
<!--
Note that it means *any* user-facing change including all aspects such as the documentation fix.
If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
If no, write 'No'.
-->
No.
### How was this patch tested?
<!--
If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
If tests were not added, please describe why they were not added and/or why it was difficult to add.
If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
-->
A unit test is added to `SparkPlanSuite`
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] dongjoon-hyun commented on pull request #37348: [SPARK-39854][SQL] replaceWithAliases should keep the original children for Generate
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #37348:
URL: https://github.com/apache/spark/pull/37348#issuecomment-1557529052
BTW, may I ask what is your previous successful Spark version, @Kimahriman ?
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] github-actions[bot] commented on pull request #37348: [SPARK-39854][SQL] replaceWithAliases should keep the original children for Generate
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #37348:
URL: https://github.com/apache/spark/pull/37348#issuecomment-1501250902
We're closing this PR because it hasn't been updated in a while. This isn't a judgement on the merit of the PR in any way. It's just a way of keeping the PR queue manageable.
If you'd like to revive this PR, please reopen it and ask a committer to remove the Stale tag!
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] jiaji-wu commented on a diff in pull request #37348: [SPARK-39854][SQL] replaceWithAliases should keep the original children for Generate
Posted by GitBox <gi...@apache.org>.
jiaji-wu commented on code in PR #37348:
URL: https://github.com/apache/spark/pull/37348#discussion_r973553085
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/SparkPlanSuite.scala:
##########
@@ -143,6 +143,48 @@ class SparkPlanSuite extends QueryTest with SharedSparkSession {
}
}
}
+
+ test("SPARK-39854: replaceWithAliases should keep the order of Generate children") {
Review Comment:
Hi @dongjoon-hyun , thanks for taking time looking into this!
The test is put in the `core` module (instead of the `catalyst` module) because it has dependency on things like `SparkSession`, `sql.functions`, which is only available there -- not sure where is the best place to put it, or are there better ways to re-write the test 😓 .
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] viirya commented on a diff in pull request #37348: [SPARK-39854][SQL] replaceWithAliases should keep the original children for Generate
Posted by GitBox <gi...@apache.org>.
viirya commented on code in PR #37348:
URL: https://github.com/apache/spark/pull/37348#discussion_r1059270228
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/SparkPlanSuite.scala:
##########
@@ -143,6 +143,48 @@ class SparkPlanSuite extends QueryTest with SharedSparkSession {
}
}
}
+
+ test("SPARK-39854: replaceWithAliases should keep the order of Generate children") {
+ import org.apache.spark.sql.functions.{explode, struct}
+ import org.apache.spark.sql.SparkSession
Review Comment:
We usually put imports at the beginning.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] Kimahriman commented on pull request #37348: [SPARK-39854][SQL] replaceWithAliases should keep the original children for Generate
Posted by "Kimahriman (via GitHub)" <gi...@apache.org>.
Kimahriman commented on PR #37348:
URL: https://github.com/apache/spark/pull/37348#issuecomment-1557514515
I think we just hit this after upgrading to Spark 3.4. Some change is now triggering the GeneratorNestedColumnAliasing where it wasn't happening before, and as a result we're getting corrupted generators because of the stale `unrequiredChildIndex` value.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] github-actions[bot] closed pull request #37348: [SPARK-39854][SQL] replaceWithAliases should keep the original children for Generate
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #37348: [SPARK-39854][SQL] replaceWithAliases should keep the original children for Generate
URL: https://github.com/apache/spark/pull/37348
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] Kimahriman commented on pull request #37348: [SPARK-39854][SQL] replaceWithAliases should keep the original children for Generate
Posted by "Kimahriman (via GitHub)" <gi...@apache.org>.
Kimahriman commented on PR #37348:
URL: https://github.com/apache/spark/pull/37348#issuecomment-1557609011
I think I'm also hitting another possibly unrelated bug with the `GeneratorNestedColumnAliasing` that I'm still trying to track down, and I still haven't figured out what changed between 3.3.2 and 3.4.0 that would cause `GeneratorNestedColumnAliasing` to trigger now for the exact same plan when it wasn't in 3.3.2.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan commented on pull request #37348: [SPARK-39854][SQL] replaceWithAliases should keep the original children for Generate
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on PR #37348:
URL: https://github.com/apache/spark/pull/37348#issuecomment-1557568197
@Kimahriman feel free to pick up this if you have an idea about how to fix it.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] dongjoon-hyun commented on pull request #37348: [SPARK-39854][SQL] replaceWithAliases should keep the original children for Generate
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #37348:
URL: https://github.com/apache/spark/pull/37348#issuecomment-1557519169
Thank you for reporting, @Kimahriman .
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #37348: [SPARK-39854][SQL] replaceWithAliases should keep the original children for Generate
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on PR #37348:
URL: https://github.com/apache/spark/pull/37348#issuecomment-1200371479
Can one of the admins verify this patch?
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] dongjoon-hyun commented on a diff in pull request #37348: [SPARK-39854][SQL] replaceWithAliases should keep the original children for Generate
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on code in PR #37348:
URL: https://github.com/apache/spark/pull/37348#discussion_r973642554
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/SparkPlanSuite.scala:
##########
@@ -143,6 +143,48 @@ class SparkPlanSuite extends QueryTest with SharedSparkSession {
}
}
}
+
+ test("SPARK-39854: replaceWithAliases should keep the order of Generate children") {
Review Comment:
If we add an end-to-end test, the Apache Spark test time increases prohibitively. We prefer to narrow down the issue and have isolated unit tests. So, in this PR, `NestedColumnAliasingSuite.scala` is the best place to have a test coverage. In short, I don't think we need a heavy end-to-end test case like this. We need to have a test case similar to the other in `NestedColumnAliasingSuite.scala`.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] dongjoon-hyun commented on a diff in pull request #37348: [SPARK-39854][SQL] replaceWithAliases should keep the original children for Generate
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on code in PR #37348:
URL: https://github.com/apache/spark/pull/37348#discussion_r973512461
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/SparkPlanSuite.scala:
##########
@@ -143,6 +143,48 @@ class SparkPlanSuite extends QueryTest with SharedSparkSession {
}
}
}
+
+ test("SPARK-39854: replaceWithAliases should keep the order of Generate children") {
Review Comment:
Thank you for providing the end-to-end test. Can we have a test case in `NestedColumnAliasingSuite.scala` because we are touching `NestedColumnAliasing`?
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] Kimahriman commented on pull request #37348: [SPARK-39854][SQL] replaceWithAliases should keep the original children for Generate
Posted by "Kimahriman (via GitHub)" <gi...@apache.org>.
Kimahriman commented on PR #37348:
URL: https://github.com/apache/spark/pull/37348#issuecomment-1557530675
3.3.2
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] dongjoon-hyun commented on pull request #37348: [SPARK-39854][SQL] replaceWithAliases should keep the original children for Generate
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on PR #37348:
URL: https://github.com/apache/spark/pull/37348#issuecomment-1367694606
I removed `State` tag. Could you rebase this PR to the master branch, @jiaji-wu ?
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] viirya commented on a diff in pull request #37348: [SPARK-39854][SQL] replaceWithAliases should keep the original children for Generate
Posted by GitBox <gi...@apache.org>.
viirya commented on code in PR #37348:
URL: https://github.com/apache/spark/pull/37348#discussion_r1059271762
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/NestedColumnAliasing.scala:
##########
@@ -184,9 +184,20 @@ object NestedColumnAliasing {
plan: LogicalPlan,
nestedFieldToAlias: Map[Expression, Alias],
attrToAliases: AttributeMap[Seq[Alias]]): LogicalPlan = {
- plan.withNewChildren(plan.children.map { plan =>
- Project(plan.output.flatMap(a => attrToAliases.getOrElse(a, Seq(a))), plan)
- }).transformExpressions {
+ val newChildPlan = plan match {
+ case g: Generate =>
+ g.withNewChildren(g.children.map { childPlan =>
+ val origOutput = childPlan.output
+ val fromAlias = childPlan.output.flatMap(a => attrToAliases.getOrElse(a, Nil))
Review Comment:
Hmm, we intend to replace some attributes with its nested fields if they are accessed on top of the plan. So we can prune unused fields later.
If we keep original outputs, I think pruning will not work actually.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] viirya commented on pull request #37348: [SPARK-39854][SQL] replaceWithAliases should keep the original children for Generate
Posted by GitBox <gi...@apache.org>.
viirya commented on PR #37348:
URL: https://github.com/apache/spark/pull/37348#issuecomment-1249961949
I'll take a look today or tomorrow. Thanks @dongjoon-hyun
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] jiaji-wu commented on a diff in pull request #37348: [SPARK-39854][SQL] replaceWithAliases should keep the original children for Generate
Posted by GitBox <gi...@apache.org>.
jiaji-wu commented on code in PR #37348:
URL: https://github.com/apache/spark/pull/37348#discussion_r973553085
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/SparkPlanSuite.scala:
##########
@@ -143,6 +143,48 @@ class SparkPlanSuite extends QueryTest with SharedSparkSession {
}
}
}
+
+ test("SPARK-39854: replaceWithAliases should keep the order of Generate children") {
Review Comment:
Hi @dongjoon-hyun , thanks for taking time looking into this!
The test is put in the `core` module (instead of the `catalyst` module) because it has dependency on things like `SparkSession`, `sql.functions`, which is only available there -- not sure where is the best place to put it, or are there better ways to re-write the test (my knowledge on that part is limited 😓).
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] jiaji-wu commented on pull request #37348: [SPARK-39854][SQL] replaceWithAliases should keep the original children for Generate
Posted by GitBox <gi...@apache.org>.
jiaji-wu commented on PR #37348:
URL: https://github.com/apache/spark/pull/37348#issuecomment-1207222130
Hi @dongjoon-hyun , is it possible to find someone to view the change (it's a relatively small one :)? Thanks.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-39854][SQL] replaceWithAliases should keep the original children for Generate [spark]
Posted by "trohwer (via GitHub)" <gi...@apache.org>.
trohwer commented on code in PR #37348:
URL: https://github.com/apache/spark/pull/37348#discussion_r1869519579
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/NestedColumnAliasing.scala:
##########
@@ -184,9 +184,20 @@ object NestedColumnAliasing {
plan: LogicalPlan,
nestedFieldToAlias: Map[Expression, Alias],
attrToAliases: AttributeMap[Seq[Alias]]): LogicalPlan = {
- plan.withNewChildren(plan.children.map { plan =>
- Project(plan.output.flatMap(a => attrToAliases.getOrElse(a, Seq(a))), plan)
- }).transformExpressions {
+ val newChildPlan = plan match {
+ case g: Generate =>
+ g.withNewChildren(g.children.map { childPlan =>
+ val origOutput = childPlan.output
+ val fromAlias = childPlan.output.flatMap(a => attrToAliases.getOrElse(a, Nil))
Review Comment:
I think, this change does not address the real issue. The real issue is, that Generate contains a list unrequiredChildIndex of child output indices, that are not needed in the Generate output. This list has to be adjusted to fit the inserted Project node of NestedColumnAliasing. Here it just fits accidentally, because the original list is included completely at the beginning of the new Project node. But this may include unnecessary outputs, that ColumnPruning is trying to avoid. I have a different proposal, that adjust the list of indices to point to the new positions after attribute aliasing: https://github.com/apache/spark/pull/49061
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] jiaji-wu commented on pull request #37348: [SPARK-39854][SQL] replaceWithAliases should keep the original children for Generate
Posted by GitBox <gi...@apache.org>.
jiaji-wu commented on PR #37348:
URL: https://github.com/apache/spark/pull/37348#issuecomment-1202503989
Any comments?
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] dongjoon-hyun commented on pull request #37348: [SPARK-39854][SQL] replaceWithAliases should keep the original children for Generate
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on PR #37348:
URL: https://github.com/apache/spark/pull/37348#issuecomment-1249962295
Thank you!
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] jiaji-wu commented on a diff in pull request #37348: [SPARK-39854][SQL] replaceWithAliases should keep the original children for Generate
Posted by GitBox <gi...@apache.org>.
jiaji-wu commented on code in PR #37348:
URL: https://github.com/apache/spark/pull/37348#discussion_r974956581
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/SparkPlanSuite.scala:
##########
@@ -143,6 +143,48 @@ class SparkPlanSuite extends QueryTest with SharedSparkSession {
}
}
}
+
+ test("SPARK-39854: replaceWithAliases should keep the order of Generate children") {
Review Comment:
I understand. will try to create a test case in `NestedColumnAliasingSuite.scala` instead.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] viirya commented on a diff in pull request #37348: [SPARK-39854][SQL] replaceWithAliases should keep the original children for Generate
Posted by GitBox <gi...@apache.org>.
viirya commented on code in PR #37348:
URL: https://github.com/apache/spark/pull/37348#discussion_r1059272165
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/NestedColumnAliasing.scala:
##########
@@ -184,9 +184,20 @@ object NestedColumnAliasing {
plan: LogicalPlan,
nestedFieldToAlias: Map[Expression, Alias],
attrToAliases: AttributeMap[Seq[Alias]]): LogicalPlan = {
- plan.withNewChildren(plan.children.map { plan =>
- Project(plan.output.flatMap(a => attrToAliases.getOrElse(a, Seq(a))), plan)
- }).transformExpressions {
+ val newChildPlan = plan match {
+ case g: Generate =>
+ g.withNewChildren(g.children.map { childPlan =>
+ val origOutput = childPlan.output
+ val fromAlias = childPlan.output.flatMap(a => attrToAliases.getOrElse(a, Nil))
Review Comment:
We may need to add a pruning test case to make sure pruning still works.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] github-actions[bot] commented on pull request #37348: [SPARK-39854][SQL] replaceWithAliases should keep the original children for Generate
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #37348:
URL: https://github.com/apache/spark/pull/37348#issuecomment-1367653269
We're closing this PR because it hasn't been updated in a while. This isn't a judgement on the merit of the PR in any way. It's just a way of keeping the PR queue manageable.
If you'd like to revive this PR, please reopen it and ask a committer to remove the Stale tag!
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan commented on pull request #37348: [SPARK-39854][SQL] replaceWithAliases should keep the original children for Generate
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on PR #37348:
URL: https://github.com/apache/spark/pull/37348#issuecomment-1367899262
shall we change `unrequiredChildIndex: Seq[Int]` to `requiredChildren: Seq[Attribute]`? then column position is not an issue anymore.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org