apache/seatunnel · error · SQLException

No result returned after running query [${minMaxQuery}]

Error message

No result returned after running query [${minMaxQuery}]

What it means

PostgresUtils.queryMinMax runs 'SELECT MIN(col), MAX(col) FROM table' to compute a chunk-split boundary for incremental snapshots. If the ResultSet has no row at all, it throws SQLException 'No result returned after running query [..]'. The comment notes this should never happen, since aggregate queries normally return one row.

Source

Thrown at seatunnel-connectors-v2/connector-cdc/connector-cdc-postgres/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/postgres/utils/PostgresUtils.java:78

    private PostgresUtils() {}

    public static Object[] queryMinMax(
            JdbcConnection jdbc, TableId tableId, String columnName, Column column)
            throws SQLException {
        columnName = quote(columnName);
        if (column != null) {
            columnName = JDBC_DIALECT.convertType(columnName, column.typeName());
        }
        final String minMaxQuery =
                String.format(
                        "SELECT MIN(%s), MAX(%s) FROM %s", columnName, columnName, quote(tableId));
        return jdbc.queryAndMap(
                minMaxQuery,
                rs -> {
                    if (!rs.next()) {
                        // this should never happen
                        throw new SQLException(
                                String.format(
                                        "No result returned after running query [%s]",
                                        minMaxQuery));
                    }
                    return SourceRecordUtils.rowToArray(rs, 2);
                });
    }

    public static long queryApproximateRowCnt(JdbcConnection jdbc, TableId tableId)
            throws SQLException {
        // The statement used to get approximate row count which is less
        // accurate than COUNT(*), but is more efficient for large table.
        final String rowCountQuery =
                String.format(
                        "SELECT reltuples FROM pg_class r WHERE relkind = 'r' AND relname = '%s';",
                        tableId.table());
        return jdbc.queryAndMap(
                rowCountQuery,

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Run the embedded minMaxQuery (printed in the message) manually in psql to check the table/column
  2. Verify the split column exists and the user can SELECT it
  3. Retry the job — snapshot split planning will re-issue the query
  4. If reproducible, check JDBC driver version compatibility with your Postgres server
Defensive patterns

Strategy: retry

Validate before calling

// run the aggregate manually before planning
String q = String.format("SELECT MIN(%s), MAX(%s) FROM %s", col, col, quotedTableId);

Try / catch

try { minMax = PostgresUtils.queryMinMax(jdbc, tableId, col); } catch (SQLException e) { log.warn("empty result for {}", e.getMessage()); }

Prevention

When it happens

Trigger: rs.next() returns false for the MIN/MAX aggregate query — practically only when the JDBC driver/conn behaves abnormally, the query was cancelled before producing a row, or the statement failed in a way that returned an empty (not failed) result set.

Common situations: Very rare in practice; seen with driver quirks, cancelled statements, or when intercepting proxies return empty results. Worth handling defensively because the message includes the exact query for debugging.

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/397377adf9613a66. Report an issue: GitHub.