apache/seatunnel · error · IllegalArgumentException

Error parsing SQL.

Error message

Error parsing SQL.

What it means

SqlToPaimonPredicateConverter.convertToPlainSelect parses the user-supplied predicate SQL with JSqlParser (CCJSqlParserUtil.parse) and wraps JSQLParserException in IllegalArgumentException('Error parsing SQL.'). It throws when the query string is not syntactically valid SQL the parser understands.

Solutions

  1. Print/inspect the SQL string and validate it is a syntactically correct SELECT
  2. Simplify the predicate to plain standard SQL (column op value with AND/OR)
  3. Quote identifiers the way JSqlParser accepts (double quotes or consistent backticks)
  4. Test the SQL with JSqlParser directly to reproduce and fix the syntax error

Example fix

// before
String sql = "SELECT * FROM t WHERE date > '2024-01-01' AND status in (1,2")"; // unbalanced
// after
String sql = "SELECT * FROM t WHERE date > '2024-01-01' AND status IN (1, 2)";
Defensive patterns

Strategy: validation

Validate before calling

try { CCJSqlParserUtil.parse(sql); } catch (JSQLParserException e) { throw new IllegalArgumentException("Invalid filter SQL: " + sql, e); }

Try / catch

try { converter.convertToPlainSelect(query); } catch (IllegalArgumentException e) { if (e.getMessage().equals("Error parsing SQL.")) { log.error("Malformed predicate SQL: {}", query); } throw e; }

Prevention

When it happens

Trigger: Passing a malformed or dialect-specific SQL predicate string (e.g. a Paimon/MySQL-only syntax, unbalanced quotes, missing WHERE, comments JSqlParser can't handle) to the converter used for Paimon source predicate pushdown.

Common situations: Users writing filter SQL in a dialect JSqlParser doesn't support (backtick vs double-quote mixing, vendor functions); typos in WHERE clauses; empty or whitespace-only fragments slipping past the earlier isBlank check.

Understand the failure class

Background: "query failed", "%w: SQL error" — wrapped database query errors in Go libraries explained — this error's family across 3 libraries.

Related errors


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

Appendix: source

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

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class SqlToPaimonPredicateConverter {

    public static PlainSelect convertToPlainSelect(String query) {
        if (StringUtils.isBlank(query)) {
            return null;
        }
        Statement statement = null;
        try {
            statement = CCJSqlParserUtil.parse(query);
        } catch (JSQLParserException e) {
            throw new IllegalArgumentException("Error parsing SQL.", e);
        }
        // Confirm that the SQL statement is a Select statement
        if (!(statement instanceof Select)) {
            throw new IllegalArgumentException("Only SELECT statements are supported.");
        }
        Select select = (Select) statement;
        Select selectBody = select.getSelectBody();
        if (!(selectBody instanceof PlainSelect)) {
            throw new IllegalArgumentException("Only simple SELECT statements are supported.");
        }
        PlainSelect plainSelect = (PlainSelect) selectBody;
        if (plainSelect.getHaving() != null
                || plainSelect.getGroupBy() != null
                || plainSelect.getOrderByElements() != null
                || plainSelect.getLimit() != null) {
            throw new IllegalArgumentException(
                    "Only SELECT statements with WHERE clause are supported. The Having, Group By, Order By, Limit clauses are currently unsupported.");
        }

View on GitHub (pinned to cf67b549a7)