apache/seatunnel · error · SQLException

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

Error message

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

What it means

Db2Utils.queryMin fetches the minimum value of the split column for a chunk, excluding an optional lower bound. It throws this SQLException when the query returns no rows, which the code comments say 'should never happen' — it is an internal invariant that every chunk query yields at least one row.

Source

Thrown at seatunnel-connectors-v2/connector-cdc/connector-cdc-db2/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/db2/utils/Db2Utils.java:116

                    }
                    return rs.getLong(1);
                });
    }

    public static Object queryMin(
            JdbcConnection jdbc, TableId tableId, String columnName, Object excludedLowerBound)
            throws SQLException {
        final String minQuery =
                String.format(
                        "SELECT MIN(%s) FROM %s WHERE %s > ?",
                        quote(columnName), quote(tableId), quote(columnName));
        return jdbc.prepareQueryAndMap(
                minQuery,
                ps -> ps.setObject(1, excludedLowerBound),
                rs -> {
                    if (!rs.next()) {
                        // this should never happen
                        throw new SQLException(
                                String.format(
                                        "No result returned after running query [%s]", minQuery));
                    }
                    return rs.getObject(1);
                });
    }

    public static Object[] sampleDataFromColumn(
            JdbcConnection jdbc, TableId tableId, String columnName, int inverseSamplingRate)
            throws SQLException {
        final String minQuery =
                String.format(
                        "SELECT %s FROM %s WHERE MOD((%s - (SELECT MIN(%s) FROM %s)), %s) = 0 ORDER BY %s",
                        quote(columnName),
                        quote(tableId),
                        quote(columnName),
                        quote(columnName),
                        quote(tableId),

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Re-run the snapshot/job — transient concurrent deletes usually resolve it
  2. Check whether rows in the chunk range are being aggressively purged during snapshotting
  3. Exclude highly volatile tables from incremental snapshot or pause purging jobs
  4. Report as a bug if reproducible on a static table
Defensive patterns

Strategy: try-catch

Try / catch

try { Object min = Db2Utils.queryMin(jdbc, minQuery, excludedLowerBound); } catch (SQLException e) { if (e.getMessage().startsWith("No result returned")) { /* skip chunk or restart snapshot */ } throw e; }

Prevention

When it happens

Trigger: Calling queryMin for a chunk whose lower bound range no longer matches any rows — e.g. rows deleted concurrently between split planning and execution, or an empty table being chunked.

Common situations: Underlying table data deleted while incremental snapshot is running; snapshot planned against a table later truncated; race between chunk splitting and reading.

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