apache/seatunnel · error · SQLException

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

Error message

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

What it means

PostgresUtils.queryNextChunkMax builds and runs a query selecting the maximum chunk-key value above a lower bound to advance incremental snapshot chunk boundaries. If the returned ResultSet contains no row it throws SQLException 'No result returned after running query [..]'.

Source

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

        }
        String query =
                String.format(
                        "SELECT MAX(%s) FROM ("
                                + "SELECT %s FROM %s WHERE %s >= ? ORDER BY %s ASC "
                                + "LIMIT %s) AS T",
                        quotedColumn,
                        quotedColumn,
                        quote(tableId),
                        quotedColumn,
                        quotedColumn,
                        chunkSize);
        return jdbc.prepareQueryAndMap(
                query,
                ps -> ps.setObject(1, includedLowerBound),
                rs -> {
                    if (!rs.next()) {
                        // this should never happen
                        throw new SQLException(
                                String.format(
                                        "No result returned after running query [%s]", query));
                    }
                    return rs.getObject(1);
                });
    }

    public static SeaTunnelRowType getSplitType(Table table) {
        List<Column> primaryKeys = table.primaryKeyColumns();
        if (primaryKeys.isEmpty()) {
            throw new SeaTunnelException(
                    String.format(
                            "Incremental snapshot for tables requires primary key,"
                                    + " but table %s doesn't have primary key.",
                            table.id()));
        }

        // use first field in primary key as the split key

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Confirm the table still exists and the connection is healthy; re-run the job (chunks restart)
  2. Check Postgres logs for cancelled statements or failover during the snapshot window
  3. Execute the query from the message manually to reproduce/validate
  4. Raise timeouts for large chunk scans or reduce chunk size
Defensive patterns

Strategy: retry

Try / catch

try { nextMax = PostgresUtils.queryNextChunkMax(jdbc, tableId, col, chunkSize, lowerBound); } catch (SQLException e) { log.warn("chunk boundary read failed, restarting split", e); }

Prevention

When it happens

Trigger: The chunk-max aggregate query returns an empty result set — abnormal driver behavior, statement cancellation, or the underlying table vanishing between chunk steps. An empty table/range normally yields a single NULL row, not an empty set.

Common situations: Long-running snapshot where the table is dropped concurrently; Postgres failover interrupting the cursor; timeouts on heavy MAX scans.

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/2c4aceda246595fc. Report an issue: GitHub.