{"record":{"id":"87268de46d69cb45","repo":"apache/seatunnel","slug":"no-result-returned-after-running-query-s","errorCode":null,"errorMessage":"No result returned after running query [%s]","messagePattern":"No result returned after running query \\[(.+?)\\]","errorType":"exception","errorClass":"java.sql.SQLException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-db2/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/db2/utils/Db2Utils.java","lineNumber":72,"sourceCode":"\n/** The utils for Db2 data source. */\n@Slf4j\npublic class Db2Utils {\n\n    public Db2Utils() {}\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        // SYSCAT.TABLES.CARD is the optimizer's cardinality estimate. It avoids COUNT(*) during\n        // split planning and falls back to 0 when RUNSTATS has not populated the estimate yet.\n        final String rowCountQuery =\n                String.format(\n                        \"SELECT COALESCE(MAX(CARD), 0) FROM SYSCAT.TABLES \"\n                                + \"WHERE TABSCHEMA = '%s' AND TABNAME = '%s'\",\n                        tableId.schema(), tableId.table());\n        return jdbc.queryAndMap(","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-cdc/connector-cdc-db2/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/db2/utils/Db2Utils.java#L54-L90","documentation":"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).","triggerScenarios":"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.","commonSituations":"Table emptied concurrently between split enumeration and min/max query; corrupted table metadata; exotic column types or expressions that alter aggregate behavior; driver quirks.","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)"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"-- preflight min/max query manually\nSELECT MIN(col), MAX(col) FROM schema.table;","typeGuard":null,"tryCatchPattern":"try { runPipeline(); } catch (SQLException e) { if (e.getMessage().startsWith(\"No result returned\")) { verifyTableNonEmpty(); retry(); } }","preventionTips":["Choose a non-null indexed chunk key column","Avoid concurrent truncation of tables during split planning","Run the reported query manually to diagnose"],"tags":["db2","cdc","jdbc","split","sql"],"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-14T05:17:10.506Z"}