Fix exact FQN matching for alert filter -filterByTableNameTestCaseBelongsTo (#17034)

This commit is contained in:
sonika-shah 2024-07-16 11:56:19 +05:30 committed by GitHub
parent 924a100ab4
commit 0853e4b5b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -255,7 +255,13 @@ public class AlertsRuleEvaluator {
EntityInterface entity = getEntity(changeEvent);
for (String name : tableNameList) {
Pattern pattern = Pattern.compile(name);
// Escape regex special characters in table name for exact matching
String escapedName = Pattern.quote(name);
// Construct regex to match table name exactly, allowing for end of string or delimiter (.)
String regex = "\\b" + escapedName + "(\\b|\\.|$)";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(entity.getFullyQualifiedName());
if (matcher.find()) {
return true;