apache/seatunnel · error · SQLException

No result returned after running query [%s]

Error message

No result returned after running query [%s]

What it means

MysqlDialect.approximateRowCntStatement runs an EXPLAIN-based row-count query (returning at least 5 columns) to estimate table size for chunk splitting. If the ResultSet is empty or has fewer than 5 metadata columns, it throws this SQLException because no reliable row count can be extracted.

Source

Thrown at seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/mysql/MysqlDialect.java:229

                                        .getFullName()
                                        .equals(table.getTablePath().getFullName()));

        if (useTableStats) {
            // The statement used to get approximate row count which is less
            // accurate than COUNT(*), but is more efficient for large table.
            TablePath tablePath = table.getTablePath();
            String useDatabaseStatement =
                    String.format("USE %s;", quoteDatabaseIdentifier(tablePath.getDatabaseName()));
            String rowCountQuery =
                    String.format("SHOW TABLE STATUS LIKE '%s';", tablePath.getTableName());

            try (Statement stmt = connection.createStatement()) {
                log.info("Split Chunk, approximateRowCntStatement: {}", useDatabaseStatement);
                stmt.execute(useDatabaseStatement);
                log.info("Split Chunk, approximateRowCntStatement: {}", rowCountQuery);
                try (ResultSet rs = stmt.executeQuery(rowCountQuery)) {
                    if (!rs.next() || rs.getMetaData().getColumnCount() < 5) {
                        throw new SQLException(
                                String.format(
                                        "No result returned after running query [%s]",
                                        rowCountQuery));
                    }
                    return rs.getLong(5);
                }
            }
        }

        return SQLUtils.countForSubquery(connection, table.getQuery());
    }

    @Override
    public StringRangeSplitDecision validateStringRangeSplit(
            Connection connection, JdbcSourceTable table, String columnName, int sampleSize)
            throws SQLException {
        if (table.getTablePath() == null
                || TablePath.DEFAULT.getFullName().equals(table.getTablePath().getFullName())) {

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Verify the target is a genuine MySQL server whose EXPLAIN output includes the rows column (5th column).
  2. Ensure the correct dialect is selected for the actual database (e.g. TiDB/OceanBase dialects) instead of MysqlDialect.
  3. Grant the connection user permission to read the target database/table so the count query returns a row.
  4. Upgrade SeaTunnel connector version if your server's EXPLAIN format changed.

Example fix

// before
url=jdbc:mysql://tidb-host:4000/db  (dialect=MySQL)
// after
url=jdbc:mysql://tidb-host:4000/db  (dialect=TiDB, which supports the expected EXPLAIN shape)
Defensive patterns

Strategy: validation

Validate before calling

// Before job: verify the count query shape
try (ResultSet rs = stmt.executeQuery(rowCountQuery)) {
    if (!rs.next() || rs.getMetaData().getColumnCount() < 5)
        throw new IllegalStateException("Server does not support expected EXPLAIN row-count shape");
}

Try / catch

catch (SQLException e) { if (e.getMessage().contains("No result returned")) { /* fall back to SELECT COUNT(*) or another split strategy */ } }

Prevention

When it happens

Trigger: Executing the dialect's rowCountQuery (e.g. EXPLAIN SELECT / information_schema query) against a MySQL-compatible database that returns no rows, or whose result shape has fewer than 5 columns — i.e. the statement form is not supported by that server.

Common situations: Pointing the MySQL dialect at a non-MySQL backend (early TiDB/OceanBase MySQL-mode versions, cloud MySQL variants) whose EXPLAIN output shape differs; querying a view or temp table where the count query yields no row; server version differences in EXPLAIN format.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


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