-
Notifications
You must be signed in to change notification settings - Fork 242
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
Support some escape chars when rewriting regexp_replace to stringReplace #11813
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -593,8 +593,9 @@ object GpuOverrides extends Logging { | |||
} | ||||
|
||||
def isSupportedStringReplacePattern(strLit: String): Boolean = { | ||||
// check for regex special characters, except for \u0000 which we can support | ||||
!regexList.filterNot(_ == "\u0000").exists(pattern => strLit.contains(pattern)) | ||||
// check for regex special characters, except for \u0000, \n, \r, and \t which we can support | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: spark-rapids/sql-plugin/src/main/scala/com/nvidia/spark/rapids/GpuOverrides.scala Line 609 in b48335a
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Deleted this comment as it is duplicated and intended to describe the internal logic of this function. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just out of curiosity is there a reason we cannot support all \uXXXX escaped characters? It is just replaced with a unicode character and we should be able to do that directly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line is to filter out regex special characters that can be replaced, normal utf8 characters are not in this list and are already supported. |
||||
val supported = Seq("\u0000", "\n", "\r", "\t") | ||||
!regexList.filterNot(supported.contains(_)).exists(pattern => strLit.contains(pattern)) | ||||
} | ||||
|
||||
def isSupportedStringReplacePattern(exp: Expression): Boolean = { | ||||
|
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.
gen = mk_str_gen('[abcdef\t]{0,3}')
We can include some of the supported characters in the input sample and also consider regex patterns like
a\ta|b\nb
, where the supported characters aren't exclusively at the end.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.
done.
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! I think we may also need to change
gen
to something likegen = mk_str_gen('[abcdef\t]{0,3}')
to include supported characters in the input.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.
oh I missed that, thanks, updated.