apache/seatunnel · error · SQLException
No result returned after running query
Error message
No result returned after running query [${sqlQuery}] What it means
PostgresDialect.queryNextChunkMax executes a single-row MAX(> bound) query to find the upper bound of the next split chunk; if the ResultSet has no row it throws SQLException "No result returned after running query". The code comments this 'should never happen' — an aggregate query always returns a row unless the underlying query/connection misbehaves.
Solutions
- Verify the table still exists and contains data when the split runs
- Confirm split_key/column and schema (search_path) resolve to the same table that was enumerated
- Check database logs for query errors at that moment
- Retry the job if it was a transient concurrent DDL issue
Example fix
// before // table truncated by another job while splitting -> empty result // after // ensure no concurrent TRUNCATE/DROP during read; or lock/snapshot: // SET TRANSACTION SNAPSHOT <snapshot_id>; before chunk queries
Defensive patterns
Strategy: retry
Validate before calling
// pre-check table visibility and non-emptiness before chunked read
try (Statement s = conn.createStatement(); ResultSet r = s.executeQuery("SELECT 1 FROM " + tableId + " LIMIT 1")) { if (!r.next()) throw new IllegalStateException("table empty/absent"); } Try / catch
try {
Object max = dialect.queryNextChunkMax(conn, tableId, column, chunkSize, includedLowerBound);
} catch (SQLException e) {
if (e.getMessage().contains("No result returned")) {
// retry with backoff or re-enumerate splits
}
} Prevention
- Avoid concurrent TRUNCATE/DROP while a read job is splitting
- Ensure schema/search_path consistency across connections
- Use appropriate split column types supported by the dialect
- Retry transient failures during chunk enumeration
When it happens
Trigger: Chunk-splitting query on the split column returns an empty ResultSet, e.g. the table/shard vanished mid-scan, the connection points to a different database/node, or the query was altered by an unsupported column type.
Common situations: Table dropped or truncated between split enumeration and chunk query; split key column with unusual types causing a malformed predicate; read-replica lag or routing to a different schema (search_path) so the table is not visible.
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
- Can't create JdbcDialect without compatible mode for…
- CommonErrorCodeDeprecated.UNSUPPORTED_DATA_TYPE
- Couldn't get timestamp utils from underlying connection
- Couldn't obtain encoding for database
- Failed creating table
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/d17ab8351ad4764e.
Report an issue: GitHub.
Appendix: source
Thrown at seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/psql/PostgresDialect.java:167
String.format(
"SELECT MAX(%s) FROM ("
+ "SELECT %s FROM %s WHERE %s >= ? ORDER BY %s ASC LIMIT %s"
+ ") AS T",
quotedColumn,
quotedColumn,
tableIdentifier(table.getTablePath()),
quotedColumn,
quotedColumn,
chunkSize);
}
try (PreparedStatement ps = connection.prepareStatement(sqlQuery)) {
ps.setObject(1, includedLowerBound);
try (ResultSet rs = ps.executeQuery()) {
if (rs.next()) {
return rs.getObject(1);
} else {
// this should never happen
throw new SQLException(
String.format("No result returned after running query [%s]", sqlQuery));
}
}
}
}
@Override
public Optional<String> getUpsertStatement(
String database, String tableName, String[] fieldNames, String[] pkNames) {
String uniqueColumns =
Arrays.stream(pkNames).map(this::quoteIdentifier).collect(Collectors.joining(", "));
final Set<String> pkNamesSet = new HashSet<>(Arrays.asList(pkNames));
String updateClause =
Arrays.stream(fieldNames)
.filter(fieldName -> !pkNamesSet.contains(fieldName))
.map(
fieldName ->
quoteIdentifier(fieldName)View on GitHub (pinned to cf67b549a7)