-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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-33890][SQL] Improve the implement of trim/trimleft/trimright #30905
Conversation
Test build #133439 has finished for PR 30905 at commit
|
Kubernetes integration test starting |
Kubernetes integration test status success |
Test build #133449 has finished for PR 30905 at commit
|
Kubernetes integration test starting |
Kubernetes integration test status failure |
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.
Looks fine as a refactoring.
@@ -756,6 +756,54 @@ trait String2TrimExpression extends Expression with ImplicitCastInputTypes { | |||
override def nullable: Boolean = children.exists(_.nullable) | |||
override def foldable: Boolean = children.forall(_.foldable) | |||
|
|||
protected def doEval(srcString: UTF8String): Any |
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.
These will definitely return UTF8String right?
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.
Yes. I updated it.
Kubernetes integration test starting |
Kubernetes integration test status success |
val srcString = evals(0) | ||
|
||
if (evals.length == 1) { | ||
ev.copy(code = evals.map(_.code) :+ |
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:
ev.copy(code = code"""
|${evals.head.code}
|...""".stripMargin
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.
OK
""") | ||
} else { | ||
val trimString = evals(1) | ||
ev.copy(code = evals.map(_.code) :+ |
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.
We can skip evaluating trim string if possible
ev.copy(code = code"""
|${evals.head.code}
|if (${srcString.isNull}) {
| ...
|} else {
| ${trimString.code}
| if (${trimString.isNull}) ...
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 idea.
Test build #133463 has finished for PR 30905 at commit
|
Test build #133488 has finished for PR 30905 at commit
|
Kubernetes integration test starting |
Kubernetes integration test status success |
Kubernetes integration test starting |
Kubernetes integration test status failure |
Test build #133491 has finished for PR 30905 at commit
|
Kubernetes integration test starting |
Kubernetes integration test status success |
Test build #133494 has finished for PR 30905 at commit
|
thanks, merging to master! |
@cloud-fan Thanks for your help! @srowen Thanks for your review. |
What changes were proposed in this pull request?
The current implement of trim/trimleft/trimright have somewhat redundant.
Why are the changes needed?
Improve the implement of trim/trimleft/trimright
Does this PR introduce any user-facing change?
'No'.
How was this patch tested?
Jenkins test