apache/seatunnel · error · IllegalArgumentException
Invalid regex pattern in `table_name`: , resolved pattern:
Error message
Invalid regex pattern in `table_name`: , resolved pattern:
What it means
compilePattern wraps Java's Pattern.compile for the database and table regex fragments derived from `table_name`. If the resolved fragment is not a valid Java regex, the PatternSyntaxException is rethrown as an IllegalArgumentException that includes both the raw `table_name` value and the resolved sub-pattern, so the user can see which part failed. This catches malformed regex like unbalanced brackets or bad quantifiers.
Source
Thrown at seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/source/config/HiveSourceTableDiscovery.java:91
}
List<String> tables = catalog.listTables(databaseName);
for (String tableName : tables) {
if (tablePattern.matcher(tableName).matches()) {
tablePaths.add(TablePath.of(databaseName, tableName));
}
}
}
}
tablePaths.sort(Comparator.comparing(TablePath::getFullName));
return tablePaths;
}
private static Pattern compilePattern(String pattern, String rawTableName) {
try {
return Pattern.compile(pattern);
} catch (PatternSyntaxException exception) {
throw new IllegalArgumentException(
"Invalid regex pattern in `table_name`: "
+ rawTableName
+ ", resolved pattern: "
+ pattern,
exception);
}
}
/**
* Treat databasePattern as an exact database name only when it doesn't contain obvious regex
* meta characters.
*/
private static boolean isExactDatabaseName(String databasePattern) {
if (databasePattern == null || databasePattern.isEmpty()) {
return false;
}
for (int i = 0; i < databasePattern.length(); i++) {
char ch = databasePattern.charAt(i);View on GitHub (pinned to cf67b549a7)
Solutions
- Fix the `table_name` regex: balance brackets/parens and quote literal dots as `\\.` in HOCON
- Test the pattern in plain Java regex before putting it in the config
- Use the documented examples like `db0.\\.*` or `db1.user_table_[0-9]+` as templates
Example fix
// before table_name = "db1.[app|web]order_\\.*" // '[' opens a char class but alternation '|' inside [ ] is literal, often unintended // after table_name = "db1.(app|web)order_\\.*"
Defensive patterns
Strategy: validation
Validate before calling
try {
java.util.regex.Pattern.compile(tableNamePattern);
} catch (java.util.regex.PatternSyntaxException e) {
throw new IllegalArgumentException("Invalid table_name regex: " + tableNamePattern, e);
} Try / catch
try {
// submit job / call discovery
} catch (IllegalArgumentException e) {
if (e.getMessage() != null && e.getMessage().contains("Invalid regex pattern")) {
// fix table_name regex and resubmit
}
} Prevention
- Test regex in plain Java before putting it in HOCON
- Escape literal dots as \\. (\\\\. in HOCON strings)
- Balance all character classes and groups
When it happens
Trigger: discoverTablePaths with use_regex=true calls compilePattern on the parsed databasePattern or tablePattern fragment and Pattern.compile throws PatternSyntaxException (e.g. `table_name = "db[.orders"` with an unclosed `[`).
Common situations: Users hand-write regex with unescaped dots or unbalanced character classes; HOCON escaping confusion (single vs double backslash) corrupts `\.` into a bare dot that then forms invalid regex; copy-pasted globs (`*`) used as regex.
Related errors
- When `use_regex` is enabled, `table_name` must be configured
- `table_name` must not be blank when `use_regex` is enabled
- Hive `table_name` must use `databasePattern.tablePattern` wh
- Hive does not support schema in `table_name` when `use_regex
- CREATE_HIVE_TABLE_FAILED
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/5fa71ae04a2185c3.
Report an issue: GitHub.