apache/seatunnel · error · IllegalArgumentException

Invalid LIKE pattern: '%s'. Supported patterns are: 'prefix%

Error message

Invalid LIKE pattern: '%s'. Supported patterns are: 'prefix%', '%suffix', and '%substring%'. Please ensure your pattern matches one of these formats.

What it means

This error is thrown by SqlToPaimonPredicateConverter.parseExpressionToPredicate when a SQL WHERE clause contains a LIKE operator whose pattern does not match one of the three supported shapes: 'prefix%', '%suffix', or '%substring%'. The converter translates JSqlParser expressions into Paimon Predicates, and LIKE patterns that cannot map to a Paimon contains/prefix/suffix predicate (e.g. '_x%' or 'a%b') are rejected rather than silently dropped.

Source

Thrown at seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/source/converter/SqlToPaimonPredicateConverter.java:297

            Matcher beginMatcher = BEGIN_PATTERN.matcher(rightVal.toString());
            if (beginMatcher.matches()) {
                return builder.startsWith(
                        columnIndex, BinaryString.fromString(beginMatcher.group(1)));
            }

            Pattern END_PATTERN = Pattern.compile("^%([^%]+)");
            Matcher endMatcher = END_PATTERN.matcher(rightVal.toString());
            if (endMatcher.matches()) {
                return builder.endsWith(columnIndex, BinaryString.fromString(endMatcher.group(1)));
            }

            Pattern CONTAINS_PATTERN = Pattern.compile("^%([^%]+)%$");
            Matcher containsMatcher = CONTAINS_PATTERN.matcher(rightVal.toString());
            if (containsMatcher.matches()) {
                return builder.contains(
                        columnIndex, BinaryString.fromString(containsMatcher.group(1)));
            }
            throw new IllegalArgumentException(
                    String.format(
                            "Invalid LIKE pattern: '%s'. Supported patterns are: 'prefix%%', '%%suffix', and '%%substring%%'. "
                                    + "Please ensure your pattern matches one of these formats.",
                            rightVal.toString()));

        } else if (expression instanceof Parenthesis) {
            Parenthesis parenthesis = (Parenthesis) expression;
            return parseExpressionToPredicate(builder, rowType, parenthesis.getExpression());
        } else if (expression instanceof InExpression) {
            return handleInExpression(builder, rowType, (InExpression) expression);
        }
        throw new IllegalArgumentException(
                "Unsupported expression type: " + expression.getClass().getSimpleName());
    }

    private static Predicate handleInExpression(
            PredicateBuilder builder, RowType rowType, InExpression expr) {
        Expression left = expr.getLeftExpression();

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Rewrite the LIKE pattern to one of 'prefix%', '%suffix', or '%substring%' forms.
  2. Move unsupported LIKE patterns out of pushdown and filter rows after read.
  3. Check for typos like double wildcards '%%' or underscore '_' in the pattern.
  4. If full LIKE support is needed, extend the converter with a Paimon PredicateBuilder fallback or an explicit runtime filter.

Example fix

// before: WHERE name LIKE 'a_b%' | // after: WHERE name LIKE 'ab%' (or filter after read)
Defensive patterns

Strategy: validation

Validate before calling

static boolean isSupportedLike(String pat) { return pat != null && (pat.matches("^[^%_]+%$") || pat.matches("^%[^%_]+$") || pat.matches("^%[^%_]+%$")); }

Try / catch

try { pred = converter.convertSqlWhereToPaimonPredicate(where, rowType); } catch (IllegalArgumentException e) { log.warn("LIKE pattern unsupported, skipping pushdown: {}", e.getMessage()); /* filter after read */ }

Prevention

When it happens

Trigger: A pushdown WHERE clause like `col LIKE 'a_b%'`, `col LIKE 'a%b'`, or any pattern with multiple/escaped wildcards reaches the LIKE branch; the compiled PREFIX/SUFFIX/CONTAINS regexes all fail to match rightVal, so the final throw fires.

Common situations: Users writing SQL filters with underscore wildcards, patterns containing escapes, or patterns copied from other SQL engines that allow regex-like LIKE; multi-wildcard patterns such as 'pre%suf'.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/454921ce9b5e2677. Report an issue: GitHub.