-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
GH-40968: [C++][Gandiva] add RE2::Options set_dot_nl(true) for Like function #40970
Merged
+37
−13
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b1d9a7a
GH-40968 add set_dot_nl(true) for Like option
xxlaykxx f63772f
fixed codestyle
xxlaykxx 20fc8b8
fixed codestyle
xxlaykxx 4695c87
refactored tests
xxlaykxx 9b9e3c7
restore Make method for LIKE
xxlaykxx e3410c6
Merge branch 'apache:main' into GH-40968
xxlaykxx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,8 @@ namespace gandiva { | |
class TestLikeHolder : public ::testing::Test { | ||
public: | ||
RE2::Options regex_op; | ||
void SetUp() { regex_op.set_dot_nl(true); } | ||
|
||
FunctionNode BuildLike(std::string pattern) { | ||
auto field = std::make_shared<FieldNode>(arrow::field("in", arrow::utf8())); | ||
auto pattern_node = | ||
|
@@ -77,6 +79,14 @@ TEST_F(TestLikeHolder, TestPcreSpecial) { | |
EXPECT_FALSE(like("xxabc")); | ||
} | ||
|
||
TEST_F(TestLikeHolder, TestPcreSpecialWithNewLine) { | ||
EXPECT_OK_AND_ASSIGN(auto const like_holder, LikeHolder::Make("%Space1.%", regex_op)); | ||
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. Can you also add a simpler test case, e.g. 'abc\nd' LIKE '%abc%' is enough to demonstate this change. |
||
|
||
auto& like = *like_holder; | ||
EXPECT_TRUE( | ||
like("[name: \"Space1.protect\"\nargs: \"count\"\ncolumn_name: \"pass_count\"]")); | ||
} | ||
|
||
TEST_F(TestLikeHolder, TestRegexEscape) { | ||
std::string res; | ||
ARROW_EXPECT_OK(RegexUtil::SqlLikePatternToPcre("#%hello#_abc_def##", '#', res)); | ||
|
@@ -91,14 +101,22 @@ TEST_F(TestLikeHolder, TestDot) { | |
EXPECT_FALSE(like("abcd")); | ||
} | ||
|
||
TEST_F(TestLikeHolder, TestMatchWithNewLine) { | ||
EXPECT_OK_AND_ASSIGN(auto const like_holder, LikeHolder::Make("%abc%", regex_op)); | ||
|
||
auto& like = *like_holder; | ||
EXPECT_TRUE(like("abc\nd")); | ||
} | ||
|
||
TEST_F(TestLikeHolder, TestMatchSubString) { | ||
EXPECT_OK_AND_ASSIGN(auto like_holder, LikeHolder::Make("%abc%", "\\")); | ||
EXPECT_OK_AND_ASSIGN(auto like_holder, LikeHolder::Make("%abc%", "\\", regex_op)); | ||
|
||
auto& like = *like_holder; | ||
EXPECT_TRUE(like("abc")); | ||
EXPECT_FALSE(like("xxabdc")); | ||
|
||
EXPECT_OK_AND_ASSIGN(like_holder, LikeHolder::Make("%ab-.^$*+?()[]{}|—/c\\%%", "\\")); | ||
EXPECT_OK_AND_ASSIGN(like_holder, | ||
LikeHolder::Make("%ab-.^$*+?()[]{}|—/c\\%%", "\\", regex_op)); | ||
|
||
auto& like_reserved_char = *like_holder; | ||
EXPECT_TRUE(like_reserved_char("XXab-.^$*+?()[]{}|—/c%d")); | ||
|
@@ -173,7 +191,7 @@ TEST_F(TestLikeHolder, TestOptimise) { | |
} | ||
|
||
TEST_F(TestLikeHolder, TestMatchOneEscape) { | ||
EXPECT_OK_AND_ASSIGN(auto const like_holder, LikeHolder::Make("ab\\_", "\\")); | ||
EXPECT_OK_AND_ASSIGN(auto const like_holder, LikeHolder::Make("ab\\_", "\\", regex_op)); | ||
|
||
auto& like = *like_holder; | ||
|
||
|
@@ -187,7 +205,7 @@ TEST_F(TestLikeHolder, TestMatchOneEscape) { | |
} | ||
|
||
TEST_F(TestLikeHolder, TestMatchManyEscape) { | ||
EXPECT_OK_AND_ASSIGN(auto const like_holder, LikeHolder::Make("ab\\%", "\\")); | ||
EXPECT_OK_AND_ASSIGN(auto const like_holder, LikeHolder::Make("ab\\%", "\\", regex_op)); | ||
|
||
auto& like = *like_holder; | ||
|
||
|
@@ -201,7 +219,8 @@ TEST_F(TestLikeHolder, TestMatchManyEscape) { | |
} | ||
|
||
TEST_F(TestLikeHolder, TestMatchEscape) { | ||
EXPECT_OK_AND_ASSIGN(auto const like_holder, LikeHolder::Make("ab\\\\", "\\")); | ||
EXPECT_OK_AND_ASSIGN(auto const like_holder, | ||
LikeHolder::Make("ab\\\\", "\\", regex_op)); | ||
|
||
auto& like = *like_holder; | ||
|
||
|
@@ -211,7 +230,7 @@ TEST_F(TestLikeHolder, TestMatchEscape) { | |
} | ||
|
||
TEST_F(TestLikeHolder, TestEmptyEscapeChar) { | ||
EXPECT_OK_AND_ASSIGN(auto const like_holder, LikeHolder::Make("ab\\_", "")); | ||
EXPECT_OK_AND_ASSIGN(auto const like_holder, LikeHolder::Make("ab\\_", "", regex_op)); | ||
|
||
auto& like = *like_holder; | ||
|
||
|
@@ -223,7 +242,7 @@ TEST_F(TestLikeHolder, TestEmptyEscapeChar) { | |
} | ||
|
||
TEST_F(TestLikeHolder, TestMultipleEscapeChar) { | ||
ASSERT_RAISES(Invalid, LikeHolder::Make("ab\\_", "\\\\").status()); | ||
ASSERT_RAISES(Invalid, LikeHolder::Make("ab\\_", "\\\\", regex_op).status()); | ||
} | ||
|
||
class TestILikeHolder : public ::testing::Test { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This breaks backward compatibility, right?
Can we keep backward compatibility?