apache/seatunnel · error · SQLException
No result returned after running query
Error message
No result returned after running query [${rowCountQuery}] What it means
Thrown by SqlServerDialect.approximateRowCntStatement when the row-count estimation query against sys.dm_db_partition_stats returns no rows. The splitter needs a row count to compute chunk boundaries, so an empty result is treated as a hard failure.
Solutions
- Verify the table exists and its name/schema matches exactly what was passed to the connector
- Grant the SQL Server user the VIEW DATABASE STATE permission so dm_db_partition_stats returns rows
- Use an account with db_owner or sysadmin rights for schema-split reads
- Check SQL Server edition: some editions/services expose DMVs differently; verify with a manual SELECT against sys.dm_db_partition_stats
Defensive patterns
Strategy: validation
Validate before calling
// Before splitting, verify the table is visible and countable SELECT SUM(st.row_count) FROM sys.dm_db_partition_stats st WHERE object_name(object_id) = 'MyTable' AND index_id < 2;
Try / catch
try {
source.open();
} catch (SQLException e) {
if (e.getMessage().startsWith("No result returned after running query")) {
// fall back to a non-approximate splitter or fix permissions
}
} Prevention
- Grant VIEW DATABASE STATE to the connector user
- Ensure exact table name/schema case matches
- Confirm table exists before starting split reads
- Test with the same SQL Server user the connector uses
When it happens
Trigger: Calling approximateRowCntStatement for a table that does not exist, is not visible to the current user (missing VIEW DATABASE STATE / VIEW DEFINITION permissions), or has no rows in sys.dm_db_partition_stats (e.g. table name case/schema mismatch via object_name(object_id)).
Common situations: Splitting a table whose name differs in case or schema from what was passed; connecting with a login lacking catalog view permissions; querying a temp or recently created empty table on certain SQL Server editions.
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
- No result returned after running query
- No result returned after running query
- No result returned after running query
- No result returned after running query
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/9a800634089b19bd.
Report an issue: GitHub.
Appendix: source
Thrown at seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/sqlserver/SqlServerDialect.java:220
TablePath tablePath = table.getTablePath();
try (Statement stmt = connection.createStatement()) {
if (StringUtils.isNotBlank(tablePath.getDatabaseName())) {
String useDatabaseStatement =
String.format(
"USE %s;",
quoteDatabaseIdentifier(tablePath.getDatabaseName()));
log.info("Split Chunk, approximateRowCntStatement: {}", useDatabaseStatement);
stmt.execute(useDatabaseStatement);
}
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;",
tablePath.getTableName());
log.info("Split Chunk, approximateRowCntStatement: {}", rowCountQuery);
try (ResultSet rs = stmt.executeQuery(rowCountQuery)) {
if (!rs.next()) {
throw new SQLException(
String.format(
"No result returned after running query [%s]",
rowCountQuery));
}
return rs.getLong(1);
}
}
}
return SQLUtils.countForSubquery(connection, table.getQuery());
}
@Override
public Object queryNextChunkMax(
Connection connection,
JdbcSourceTable table,
String columnName,
int chunkSize,
Object includedLowerBound)View on GitHub (pinned to cf67b549a7)