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

Exclude all unicode line terminator characters from matching dot #5424

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,8 @@ class CudfRegexTranspiler(mode: RegexMode) {
case RegexChar(ch) => ch match {
case '.' =>
// workaround for https://github.com/rapidsai/cudf/issues/9619
RegexCharacterClass(negated = true, ListBuffer(RegexChar('\r'), RegexChar('\n')))
val terminatorChars = ListBuffer('\r', '\n', '\u0085', '\u2028', '\u2029')
RegexCharacterClass(negated = true, terminatorChars.map(RegexChar))
NVnavkumar marked this conversation as resolved.
Show resolved Hide resolved
case '$' if mode == RegexSplitMode || mode == RegexReplaceMode =>
// see https://github.com/NVIDIA/spark-rapids/issues/4533
throw new RegexUnsupportedException("line anchor $ is not supported in split or replace")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,11 @@ class RegularExpressionTranspilerSuite extends FunSuite with Arm {
"[0-9]{2}:[0-9]{2}:[0-9]{2})" +
"(.[1-9]*(?:0)?[1-9]+)?(.0*[1-9]+)?(?:.0*)?\\z"

// input and output should be identical except for `.` being replaced with `[^\r\n]` and
// `\z` being replaced with `$`
// input and output should be identical except for `.` being replaced
// with `[^\r\n\u0085\u2028\u2029]` and `\z` being replaced with `$`
doTranspileTest(TIMESTAMP_TRUNCATE_REGEX,
TIMESTAMP_TRUNCATE_REGEX
.replaceAll("\\.", "[^\r\n]")
.replaceAll("\\.", "[^\r\n\u0085\u2028\u2029]")
.replaceAll("\\\\z", "\\$"))
}

Expand Down