Skip to content
Open
Changes from all commits
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 @@ -36,6 +36,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import static org.apache.paimon.flink.action.MultiTablesSinkMode.COMBINED;
Expand Down Expand Up @@ -302,19 +303,19 @@ public static String combinedModeTableList(
// be excluded by excluding pattern at the same time
String includingPattern =
String.format("(%s)\\.(%s)", databasePattern, includingTablePattern);

LOG.info("Combined mode including pattern is {}", includingPattern);
if (excludedTables.isEmpty()) {
return includingPattern;
}

// Use Pattern.quote to escape special regex characters (e.g., '$' in mysql table name)
// in database and table names, ensuring exact literal matching in the regex.
String excludingPattern =
excludedTables.stream()
.map(
t ->
String.format(
"(^%s$)",
t.getDatabaseName() + "\\." + t.getObjectName()))
.map(Identifier::getFullName)
.map(n -> String.format("(^%s$)", Pattern.quote(n)))
.collect(Collectors.joining("|"));
LOG.info("Combined mode excluding pattern is {}", excludingPattern);
excludingPattern = "?!" + excludingPattern;
return String.format("(%s)(%s)", excludingPattern, includingPattern);
}
Expand Down