{"record":{"id":"80a5ad407d788929","repo":"apache/seatunnel","slug":"no-result-returned-after-running-query-s-80a5ad","errorCode":null,"errorMessage":"No result returned after running query [%s]","messagePattern":"No result returned after running query \\[(.+?)\\]","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-sqlserver/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/sqlserver/utils/SqlServerUtils.java","lineNumber":76,"sourceCode":"\n/** The utils for SqlServer data source. */\n@Slf4j\npublic class SqlServerUtils {\n\n    public SqlServerUtils() {}\n\n    public static Object[] queryMinMax(JdbcConnection jdbc, TableId tableId, String columnName)\n            throws SQLException {\n        final String minMaxQuery =\n                String.format(\n                        \"SELECT MIN(%s), MAX(%s) FROM %s\",\n                        quote(columnName), quote(columnName), quote(tableId));\n        return jdbc.queryAndMap(\n                minMaxQuery,\n                rs -> {\n                    if (!rs.next()) {\n                        // this should never happen\n                        throw new SQLException(\n                                String.format(\n                                        \"No result returned after running query [%s]\",\n                                        minMaxQuery));\n                    }\n                    return SourceRecordUtils.rowToArray(rs, 2);\n                });\n    }\n\n    public static long queryApproximateRowCnt(JdbcConnection jdbc, TableId tableId)\n            throws SQLException {\n        // The statement used to get approximate row count which is less\n        // accurate than COUNT(*), but is more efficient for large table.\n        final String useDatabaseStatement = String.format(\"USE %s;\", quote(tableId.catalog()));\n        final String rowCountQuery =\n                String.format(\n                        \"SELECT Total_Rows = SUM(st.row_count) FROM sys\"\n                                + \".dm_db_partition_stats st WHERE object_name(object_id) = '%s' AND index_id < 2;\",\n                        tableId.table());","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-cdc/connector-cdc-sqlserver/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/sqlserver/utils/SqlServerUtils.java#L58-L94","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","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"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"-- Confirm table is non-empty before snapshot\nSELECT COUNT(*) FROM dbo.Orders;","typeGuard":null,"tryCatchPattern":"// Treat as transient and retry the job/failing task\ntry {\n    startJob(cfg);\n} catch (Exception e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"No result returned\")) {\n        retryWithBackoff(() -> startJob(cfg), 2);\n    } else throw e;\n}","preventionTips":["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"],"tags":["cdc","sqlserver","jdbc","empty-result"],"backgroundTag":"empty-result-set","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}