Skip to content

Commit

Permalink
Revert "fix: regexp_extract returns match in mismatched group (facebo…
Browse files Browse the repository at this point in the history
…okincubator#12109)"

This reverts commit 58ff4ac.
  • Loading branch information
zhouyuan committed Jan 23, 2025
1 parent b0de54a commit 99a1f5b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
10 changes: 2 additions & 8 deletions velox/functions/lib/Re2Functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,8 @@ bool re2Extract(
}
} else {
const re2::StringPiece extracted = groups[groupId];
// Check if the extracted data is null.
if (extracted.data()) {
result.setNoCopy(row, StringView(extracted.data(), extracted.size()));
return !StringView::isInline(extracted.size());
} else {
result.setNull(row, true);
return false;
}
result.setNoCopy(row, StringView(extracted.data(), extracted.size()));
return !StringView::isInline(extracted.size());
}
}

Expand Down
3 changes: 0 additions & 3 deletions velox/functions/lib/tests/Re2FunctionsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,6 @@ void testRe2Extract(F&& regexExtract) {
EXPECT_EQ(regexExtract(std::nullopt, "\\d+", 0), std::nullopt);
EXPECT_EQ(regexExtract(" 123 ", std::nullopt, 0), std::nullopt);
EXPECT_EQ(regexExtract(" 123 ", "\\d+", std::nullopt), std::nullopt);
// Group case that mismatch.
EXPECT_EQ(
regexExtract("rat cat\nbat dog", "ra(.)|blah(.)(.)", 2), std::nullopt);
}

TEST_F(Re2FunctionsTest, regexExtract) {
Expand Down

0 comments on commit 99a1f5b

Please sign in to comment.