apache/seatunnel · error · java.sql.SQLException
No result returned after running query [%s]
Error message
No result returned after running query [%s]
What it means
Db2Utils.queryMinMax runs a SELECT MIN/MAX query for a split's column bounds and expects at least one row. If the ResultSet is empty, it throws a SQLException 'No result returned after running query [<query>]' (the comment notes this should never happen since MIN/MAX over a non-empty table always returns a 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:72
/** The utils for Db2 data source. */
@Slf4j
public class Db2Utils {
public Db2Utils() {}
public static Object[] queryMinMax(JdbcConnection jdbc, TableId tableId, String columnName)
throws SQLException {
final String minMaxQuery =
String.format(
"SELECT MIN(%s), MAX(%s) FROM %s",
quote(columnName), quote(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 {
// SYSCAT.TABLES.CARD is the optimizer's cardinality estimate. It avoids COUNT(*) during
// split planning and falls back to 0 when RUNSTATS has not populated the estimate yet.
final String rowCountQuery =
String.format(
"SELECT COALESCE(MAX(CARD), 0) FROM SYSCAT.TABLES "
+ "WHERE TABSCHEMA = '%s' AND TABNAME = '%s'",
tableId.schema(), tableId.table());
return jdbc.queryAndMap(View on GitHub (pinned to cf67b549a7)
Solutions
- Verify the table contains rows and the split column exists and is non-empty for aggregation
- Inspect the interpolated query text in the message and run it manually against DB2
- Retry the job — a concurrent truncate/delete may have raced with split planning
- Re-check the chunk key column configuration (choose a non-null indexed column)
Defensive patterns
Strategy: retry
Validate before calling
-- preflight min/max query manually SELECT MIN(col), MAX(col) FROM schema.table;
Try / catch
try { runPipeline(); } catch (SQLException e) { if (e.getMessage().startsWith("No result returned")) { verifyTableNonEmpty(); retry(); } } Prevention
- Choose a non-null indexed chunk key column
- Avoid concurrent truncation of tables during split planning
- Run the reported query manually to diagnose
When it happens
Trigger: The min/max aggregate query returns an empty result set — effectively only possible if the query is malformed, the table is a view with no rows plus filtering, or driver behavior differs from expectations.
Common situations: Table emptied concurrently between split enumeration and min/max query; corrupted table metadata; exotic column types or expressions that alter aggregate behavior; driver quirks.
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
- Error to discover tables:
- Error to check tables:
- Failed to split chunks for table " + tableId
- Read the binlog offset error
- Failed to disable auto commit for Db2 CDC connection
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/87268de46d69cb45.
Report an issue: GitHub.