apache/seatunnel · error · SQLException
No result returned after running query [%s]
Error message
No result returned after running query [%s]
What it means
SqlServerUtils.queryMinMax runs SELECT MIN/MAX on the split column and throws SQLException when the result set has no rows. The comment says 'this should never happen' — aggregates normally return one row — so an empty result indicates the table or chunk is unexpectedly empty or the query was malformed.
Source
Thrown at seatunnel-connectors-v2/connector-cdc/connector-cdc-sqlserver/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/sqlserver/utils/SqlServerUtils.java:76
/** The utils for SqlServer data source. */
@Slf4j
public class SqlServerUtils {
public SqlServerUtils() {}
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 {
// The statement used to get approximate row count which is less
// accurate than COUNT(*), but is more efficient for large table.
final String useDatabaseStatement = String.format("USE %s;", quote(tableId.catalog()));
final String rowCountQuery =
String.format(
"SELECT Total_Rows = SUM(st.row_count) FROM sys"
+ ".dm_db_partition_stats st WHERE object_name(object_id) = '%s' AND index_id < 2;",
tableId.table());View on GitHub (pinned to cf67b549a7)
Solutions
- Verify the table still exists and contains rows when the job starts
- Re-run the job; concurrent DDL/drop during startup is the usual cause
- Check the rendered minMaxQuery in logs and run it manually against SQL Server
- If split column values are being filtered by permissions, grant the login full SELECT
Defensive patterns
Strategy: retry
Validate before calling
-- Confirm table is non-empty before snapshot SELECT COUNT(*) FROM dbo.Orders;
Try / catch
// Treat as transient and retry the job/failing task
try {
startJob(cfg);
} catch (Exception e) {
if (e.getMessage() != null && e.getMessage().contains("No result returned")) {
retryWithBackoff(() -> startJob(cfg), 2);
} else throw e;
} Prevention
- Avoid truncating/dropping tables during job startup
- Verify the split column exists and the table has rows
- Check rendered min/max query in logs against live data
- Avoid permission-based row filtering for the connector login
When it happens
Trigger: queryAndMap on the min/max query where rs.next() is false — the table is empty or the SELECT MIN(col), MAX(col) FROM table statement matched nothing.
Common situations: Table truncated/dropped between split enumeration and min/max query; race with concurrent schema changes; extremely rare DB edge where an aggregate returns no row (e.g. permission-filtered data).
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
- No result returned after running query [%s]
- No result returned after running query [%s]
- Couldn't obtain database name
- Error to discover tables: ${e.getMessage()}
- Error to check tables: ${e.getMessage()}
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/80a5ad407d788929.
Report an issue: GitHub.