Skip to content

Commit

Permalink
Documentation and exception update for ascii character classes
Browse files Browse the repository at this point in the history
  • Loading branch information
codyschierbeck committed Mar 6, 2024
1 parent 4a2929d commit f5edfec
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions velox/docs/functions/spark/regexp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ See https://github.com/google/re2/wiki/Syntax for more information.

regexp_replace will throw an exception if ``string`` contains an invalid UTF-8 character, or if ``pattern`` does not conform to RE2 syntax: https://github.com/google/re2/wiki/Syntax.

regexp_replace does not support character class union, intersection, or difference and will throw an exception if they are detected within the provided ``pattern``.
regexp_replace does not support named ASCII character classes or ASCII character class union, intersection, or difference and will throw an exception if they are detected within the provided ``pattern``.


Parameters:
Expand All @@ -67,7 +67,7 @@ See https://github.com/google/re2/wiki/Syntax for more information.

regexp_replace will throw an exception if ``string`` contains an invalid UTF-8 character, if ``position`` is less than 1, or if ``pattern`` does not conform to RE2 syntax: https://github.com/google/re2/wiki/Syntax.

regexp_replace does not support character class union, intersection, or difference and will throw an exception if they are detected within the provided ``pattern``.
regexp_replace does not support named ASCII character classes or character class union, intersection, or difference and will throw an exception if they are detected within the provided ``pattern``.


This function is 1-indexed, meaning the position of the first character is 1.
Expand Down
2 changes: 1 addition & 1 deletion velox/functions/sparksql/RegexFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void checkForCompatiblePattern(
} else if (*c == '[') {
if (charClassStart) {
VELOX_USER_FAIL(
"{} does not support character class union, intersection, "
"{} does not support named ASCII character classes or class union, intersection, "
"or difference ([a[b]], [a&&[b]], [a&&[^b]])",
functionName);
}
Expand Down
6 changes: 3 additions & 3 deletions velox/functions/sparksql/tests/RegexFunctionsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,13 @@ TEST_F(RegexFunctionsTest, regexpReplaceWithEmptyString) {
TEST_F(RegexFunctionsTest, regexBadJavaPattern) {
VELOX_ASSERT_THROW(
testRegexpReplace("[]", "[a[b]]", ""),
"regexp_replace does not support character class union, intersection, or difference ([a[b]], [a&&[b]], [a&&[^b]])");
"regexp_replace does not support named ASCII character classes or class union, intersection, or difference ([a[b]], [a&&[b]], [a&&[^b]])");
VELOX_ASSERT_THROW(
testRegexpReplace("[]", "[a&&[b]]", ""),
"regexp_replace does not support character class union, intersection, or difference ([a[b]], [a&&[b]], [a&&[^b]])");
"regexp_replace does not support named ASCII character classes or class union, intersection, or difference ([a[b]], [a&&[b]], [a&&[^b]])");
VELOX_ASSERT_THROW(
testRegexpReplace("[]", "[a&&[^b]]", ""),
"regexp_replace does not support character class union, intersection, or difference ([a[b]], [a&&[b]], [a&&[^b]])");
"regexp_replace does not support named ASCII character classes or class union, intersection, or difference ([a[b]], [a&&[b]], [a&&[^b]])");
}


Expand Down

0 comments on commit f5edfec

Please sign in to comment.