-
Notifications
You must be signed in to change notification settings - Fork 28k
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
Conversation
s"${patternClass} pattern = $patternClass.compile($literalRight);" | ||
} else { | ||
s""" | ||
StringBuilder regex = new StringBuilder("(?s)"); |
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.
I am not sure, if StringBuilder
is 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)
Test build #37923 has finished for PR 7561 at commit
|
Test build #37937 has finished for PR 7561 at commit
|
Test build #37940 has finished for PR 7561 at commit
|
Test build #37945 has finished for PR 7561 at commit
|
retest this please. |
Test build #43 has finished for PR 7561 at commit
|
Test build #37955 has finished for PR 7561 at commit
|
val pattern = ctx.freshName("pattern") | ||
|
||
val literalRight: String = right match { | ||
case x @ Literal(value: String, StringType) => escape(value) |
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.
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.
cc @davies |
val patternClass = classOf[Pattern].getName | ||
val pattern = ctx.freshName("pattern") | ||
|
||
val literalRight: String = right match { |
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.
Once we can cache the compiled pattern, this is not needed anymore.
Test build #38052 has finished for PR 7561 at commit
|
retest this please. |
Test build #53 has finished for PR 7561 at commit
|
Test build #38056 has finished for PR 7561 at commit
|
Looks like Jenkins is not working now? |
retest this please. |
Test build #70 has finished for PR 7561 at commit
|
Test build #38153 has finished for PR 7561 at commit
|
cc @cloud-fan for review |
$patternCode | ||
} | ||
} | ||
""" |
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.
You can use nullSafeCodeGen
here.
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.
Thanks. Updated.
Test build #38546 has finished for PR 7561 at commit
|
Jenkins, retest this please. |
Same failure found in #7693. @liancheng is fixing it now. Currently retesting might also get failed. |
retest this please. |
Test build #128 has finished for PR 7561 at commit
|
Test build #38630 has finished for PR 7561 at commit
|
ping @rxin |
val pattern = ctx.freshName("pattern") | ||
|
||
nullSafeCodeGen(ctx, ev, (eval1, eval2) => { | ||
val patternCode = |
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: Do we need this?
LGTM, merging this into master, the unneeded variable will be removed while merging. |
@davies this one too - need unit tests that use NonFoldableLiteral |
|
||
nullSafeCodeGen(ctx, ev, (eval1, eval2) => { | ||
val patternCode = | ||
if (right.foldable) { |
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.
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)
}
Actually I didn't merge this, so go ahead. |
@viirya can you update the unit test for rlike and like to use NonFoldableLiteral in addition to Literal? |
@rxin ok. |
LGTM |
Test build #39152 has finished for PR 7561 at commit
|
Thanks - I've merged this. |
Test build #39155 has finished for PR 7561 at commit
|
JIRA: https://issues.apache.org/jira/browse/SPARK-9152
This PR implements code generation for
Like
andRLike
.