apache/seatunnel · error · IllegalArgumentException

Only simple SELECT statements are supported.

Error message

Only simple SELECT statements are supported.

What it means

convertToPlainSelect also requires the parsed Select body to be a PlainSelect; compound constructs like UNION/INTERSECT/SetOperation selects fail the instanceof check and throw IllegalArgumentException('Only simple SELECT statements are supported.').

Source

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

    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.");
        }
        return plainSelect;
    }

    public static int[] convertSqlSelectToPaimonProjectionIndex(
            String[] fieldNames, PlainSelect plainSelect) {
        int[] projectionIndex = null;
        List<SelectItem<?>> selectItems = plainSelect.getSelectItems();

        List<String> columnNames = new ArrayList<>();

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Rewrite as a single flat SELECT with combined WHERE conditions (e.g. replace UNION with OR where semantics allow)
  2. Split into multiple source queries/jobs if UNION semantics are required
  3. Remove set operations and use simple predicates that Paimon can push down

Example fix

// before
String sql = "SELECT * FROM t WHERE a=1 UNION SELECT * FROM t WHERE b=2";
// after
String sql = "SELECT * FROM t WHERE a=1 OR b=2";
Defensive patterns

Strategy: validation

Validate before calling

if (sql.toUpperCase().matches(".*(UNION|INTERSECT|MINUS).*")) throw new IllegalArgumentException("Set operations not supported in filter SQL");

Try / catch

try { converter.convertToPlainSelect(query); } catch (IllegalArgumentException e) { if (e.getMessage().contains("simple SELECT")) { /* rewrite as flat SELECT */ } throw e; }

Prevention

When it happens

Trigger: Passing a UNION/INTERSECT/MINUS (set-operation) query, or another non-plain Select form, to the Paimon predicate converter instead of a single flat SELECT.

Common situations: Users trying to express complex filters via UNION of conditions; query templates that join multiple selects; migration from SQL engines that allow set operations in pushdown filters.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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