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-9152][SQL] Implement code generation for Like and RLike #7561

Closed
wants to merge 12 commits into from

Conversation

viirya
Copy link
Member

@viirya viirya commented Jul 21, 2015

JIRA: https://issues.apache.org/jira/browse/SPARK-9152

This PR implements code generation for Like and RLike.

s"${patternClass} pattern = $patternClass.compile($literalRight);"
} else {
s"""
StringBuilder regex = new StringBuilder("(?s)");
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure, if StringBuilderis imported. If not define somewhere val sb = classOf[StringBuilder].getName and use $sb

You shouldn't use regex. You can create a save variable name with ctx.freshName. (Same for all other variable names)

@SparkQA
Copy link

SparkQA commented Jul 21, 2015

Test build #37923 has finished for PR 7561 at commit 69f0fb6.

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

@SparkQA
Copy link

SparkQA commented Jul 21, 2015

Test build #37937 has finished for PR 7561 at commit 6cffe3c.

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

@SparkQA
Copy link

SparkQA commented Jul 21, 2015

Test build #37940 has finished for PR 7561 at commit a0fb76e.

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

@SparkQA
Copy link

SparkQA commented Jul 21, 2015

Test build #37945 has finished for PR 7561 at commit aea58e0.

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

@viirya
Copy link
Member Author

viirya commented Jul 21, 2015

retest this please.

@SparkQA
Copy link

SparkQA commented Jul 21, 2015

Test build #43 has finished for PR 7561 at commit aea58e0.

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

@SparkQA
Copy link

SparkQA commented Jul 21, 2015

Test build #37955 has finished for PR 7561 at commit aea58e0.

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

val pattern = ctx.freshName("pattern")

val literalRight: String = right match {
case x @ Literal(value: String, StringType) => escape(value)
Copy link
Contributor

Choose a reason for hiding this comment

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

rather than checking whether it is a string literal, i think you should check whether the expression is foldable, and and if yes, fold it.

@rxin
Copy link
Contributor

rxin commented Jul 22, 2015

cc @davies

val patternClass = classOf[Pattern].getName
val pattern = ctx.freshName("pattern")

val literalRight: String = right match {
Copy link
Contributor

Choose a reason for hiding this comment

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

Once we can cache the compiled pattern, this is not needed anymore.

@SparkQA
Copy link

SparkQA commented Jul 22, 2015

Test build #38052 has finished for PR 7561 at commit 696d451.

  • This patch fails to build.
  • This patch merges cleanly.
  • This patch adds no public classes.

@viirya
Copy link
Member Author

viirya commented Jul 22, 2015

retest this please.

@SparkQA
Copy link

SparkQA commented Jul 22, 2015

Test build #53 has finished for PR 7561 at commit 696d451.

  • This patch fails to build.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jul 22, 2015

Test build #38056 has finished for PR 7561 at commit 696d451.

  • This patch fails to build.
  • This patch merges cleanly.
  • This patch adds no public classes.

@viirya
Copy link
Member Author

viirya commented Jul 22, 2015

Looks like Jenkins is not working now?

@viirya
Copy link
Member Author

viirya commented Jul 23, 2015

retest this please.

@SparkQA
Copy link

SparkQA commented Jul 23, 2015

Test build #70 has finished for PR 7561 at commit 696d451.

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

@SparkQA
Copy link

SparkQA commented Jul 23, 2015

Test build #38153 has finished for PR 7561 at commit 696d451.

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

@viirya
Copy link
Member Author

viirya commented Jul 24, 2015

ping @davies @rxin

@rxin
Copy link
Contributor

rxin commented Jul 27, 2015

cc @cloud-fan for review

$patternCode
}
}
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use nullSafeCodeGen here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks. Updated.

@SparkQA
Copy link

SparkQA commented Jul 27, 2015

Test build #38546 has finished for PR 7561 at commit 50df9a8.

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

@rxin
Copy link
Contributor

rxin commented Jul 27, 2015

Jenkins, retest this please.

@viirya
Copy link
Member Author

viirya commented Jul 27, 2015

Same failure found in #7693. @liancheng is fixing it now. Currently retesting might also get failed.

@viirya
Copy link
Member Author

viirya commented Jul 28, 2015

retest this please.

@SparkQA
Copy link

SparkQA commented Jul 28, 2015

Test build #128 has finished for PR 7561 at commit 50df9a8.

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

@SparkQA
Copy link

SparkQA commented Jul 28, 2015

Test build #38630 has finished for PR 7561 at commit 50df9a8.

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

@viirya
Copy link
Member Author

viirya commented Jul 30, 2015

ping @rxin

val pattern = ctx.freshName("pattern")

nullSafeCodeGen(ctx, ev, (eval1, eval2) => {
val patternCode =
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Do we need this?

@davies
Copy link
Contributor

davies commented Jul 30, 2015

LGTM, merging this into master, the unneeded variable will be removed while merging.

@rxin
Copy link
Contributor

rxin commented Jul 30, 2015

@davies this one too - need unit tests that use NonFoldableLiteral


nullSafeCodeGen(ctx, ev, (eval1, eval2) => {
val patternCode =
if (right.foldable) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should move this out of nullSafeCodeGen, or it will also eval the eval2.

if (right.foldable) {
  val rVal = right.eval()
  if (rVal != null) {
  } else {
   "boolean {ev.isNull} = true;  xxx"
  }
} else {
  nullSafeCodeGen(xxx)
}

@davies
Copy link
Contributor

davies commented Jul 30, 2015

Actually I didn't merge this, so go ahead.

@rxin
Copy link
Contributor

rxin commented Jul 31, 2015

@viirya can you update the unit test for rlike and like to use NonFoldableLiteral in addition to Literal?

@viirya
Copy link
Member Author

viirya commented Jul 31, 2015

@rxin ok.

@rxin
Copy link
Contributor

rxin commented Jul 31, 2015

LGTM

@SparkQA
Copy link

SparkQA commented Jul 31, 2015

Test build #39152 has finished for PR 7561 at commit ccd1b43.

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

@rxin
Copy link
Contributor

rxin commented Jul 31, 2015

Thanks - I've merged this.

@asfgit asfgit closed this in 0244170 Jul 31, 2015
@SparkQA
Copy link

SparkQA commented Jul 31, 2015

Test build #39155 has finished for PR 7561 at commit fe5641b.

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

@viirya viirya deleted the like_rlike_codegen branch December 27, 2023 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants