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-33890][SQL] Improve the implement of trim/trimleft/trimright #30905

Closed
wants to merge 47 commits into from

Conversation

beliefer
Copy link
Contributor

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

beliefer and others added 30 commits June 19, 2020 10:36
@SparkQA
Copy link

SparkQA commented Dec 28, 2020

Test build #133439 has finished for PR 30905 at commit 7d32023.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Dec 28, 2020

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/38030/

@SparkQA
Copy link

SparkQA commented Dec 28, 2020

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/38030/

@SparkQA
Copy link

SparkQA commented Dec 28, 2020

Test build #133449 has finished for PR 30905 at commit ba91af5.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Dec 28, 2020

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/38038/

@SparkQA
Copy link

SparkQA commented Dec 28, 2020

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/38038/

Copy link
Member

@srowen srowen left a 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
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. I updated it.

@SparkQA
Copy link

SparkQA commented Dec 29, 2020

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/38052/

@SparkQA
Copy link

SparkQA commented Dec 29, 2020

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/38052/

val srcString = evals(0)

if (evals.length == 1) {
ev.copy(code = evals.map(_.code) :+
Copy link
Contributor

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 

Copy link
Contributor Author

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) :+
Copy link
Contributor

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}) ...

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 idea.

@SparkQA
Copy link

SparkQA commented Dec 29, 2020

Test build #133463 has finished for PR 30905 at commit 42f75f3.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Dec 29, 2020

Test build #133488 has finished for PR 30905 at commit b8ad0cb.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Dec 29, 2020

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/38076/

@SparkQA
Copy link

SparkQA commented Dec 29, 2020

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/38076/

@SparkQA
Copy link

SparkQA commented Dec 29, 2020

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/38080/

@SparkQA
Copy link

SparkQA commented Dec 29, 2020

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/38080/

@SparkQA
Copy link

SparkQA commented Dec 29, 2020

Test build #133491 has finished for PR 30905 at commit fb13fe4.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Dec 29, 2020

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/38083/

@SparkQA
Copy link

SparkQA commented Dec 29, 2020

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/38083/

@SparkQA
Copy link

SparkQA commented Dec 29, 2020

Test build #133494 has finished for PR 30905 at commit 3331b48.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@cloud-fan
Copy link
Contributor

thanks, merging to master!

@cloud-fan cloud-fan closed this in 687f465 Dec 30, 2020
@beliefer
Copy link
Contributor Author

@cloud-fan Thanks for your help! @srowen Thanks for your review.

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.

4 participants