[SPARK-48922][SQL][3.5] Avoid redundant array transform of identical expression for map type#50265
Closed
wForget wants to merge 1 commit into
Closed
[SPARK-48922][SQL][3.5] Avoid redundant array transform of identical expression for map type#50265wForget wants to merge 1 commit into
wForget wants to merge 1 commit into
Conversation
…ssion for map type ### What changes were proposed in this pull request? Similar to apache#47843, this patch avoids ArrayTransform in `resolveMapType` function if the resolution expression is the same as input param. ### Why are the changes needed? My previous pr apache#47381 was not merged, but I still think it is an optimization, so I reopened it. During the upgrade from Spark 3.1.1 to 3.5.0, I found a performance regression in map type inserts. There are some extra conversion expressions in project before insert, which doesn't seem to be always necessary. ``` map_from_arrays(transform(map_keys(map#516), lambdafunction(lambda key#652, lambda key#652, false)), transform(map_values(map#516), lambdafunction(lambda value#654, lambda value#654, false))) AS map#656 ``` ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? added unit test ### Was this patch authored or co-authored using generative AI tooling? No Closes apache#50245 from wForget/SPARK-48922. Authored-by: wforget <643348094@qq.com> Signed-off-by: beliefer <beliefer@163.com> (cherry picked from commit 1be108e)
Contributor
|
LGTM Thank you @wForget |
viirya
approved these changes
Mar 13, 2025
beliefer
pushed a commit
that referenced
this pull request
Mar 13, 2025
…expression for map type ### What changes were proposed in this pull request? Backports #50245 to 3.5 Similar to #47843, this patch avoids ArrayTransform in `resolveMapType` function if the resolution expression is the same as input param. ### Why are the changes needed? My previous pr #47381 was not merged, but I still think it is an optimization, so I reopened it. During the upgrade from Spark 3.1.1 to 3.5.0, I found a performance regression in map type inserts. There are some extra conversion expressions in project before insert, which doesn't seem to be always necessary. ``` map_from_arrays(transform(map_keys(map#516), lambdafunction(lambda key#652, lambda key#652, false)), transform(map_values(map#516), lambdafunction(lambda value#654, lambda value#654, false))) AS map#656 ``` ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? added unit test ### Was this patch authored or co-authored using generative AI tooling? No Closes #50245 from wForget/SPARK-48922. Authored-by: wforget <643348094qq.com> Signed-off-by: beliefer <beliefer163.com> (cherry picked from commit 1be108e) Closes #50265 from wForget/SPARK-48922-3.5. Authored-by: wforget <643348094@qq.com> Signed-off-by: beliefer <beliefer@163.com>
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Backports #50245 to 3.5
Similar to #47843, this patch avoids ArrayTransform in
resolveMapTypefunction if the resolution expression is the same as input param.Why are the changes needed?
My previous pr #47381 was not merged, but I still think it is an optimization, so I reopened it.
During the upgrade from Spark 3.1.1 to 3.5.0, I found a performance regression in map type inserts.
There are some extra conversion expressions in project before insert, which doesn't seem to be always necessary.
Does this PR introduce any user-facing change?
No
How was this patch tested?
added unit test
Was this patch authored or co-authored using generative AI tooling?
No
Closes #50245 from wForget/SPARK-48922.
Authored-by: wforget 643348094@qq.com
Signed-off-by: beliefer beliefer@163.com
(cherry picked from commit 1be108e)