{"record":{"id":"e17bc7e98aff7a5a","repo":"apache/seatunnel","slug":"no-result-returned-after-running-query-rowcount","errorCode":null,"errorMessage":"No result returned after running query [${rowCountQuery}]","messagePattern":"No result returned after running query \\[(.+?)\\]","errorType":"exception","errorClass":"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":94,"sourceCode":"                    }\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(\n                rowCountQuery,\n                rs -> {\n                    if (!rs.next()) {\n                        throw new SQLException(\n                                String.format(\n                                        \"No result returned after running query [%s]\",\n                                        rowCountQuery));\n                    }\n                    return rs.getLong(1);\n                });\n    }\n\n    public static Object queryMin(\n            JdbcConnection jdbc, TableId tableId, String columnName, Object excludedLowerBound)\n            throws SQLException {\n        final String minQuery =\n                String.format(\n                        \"SELECT MIN(%s) FROM %s WHERE %s > ?\",\n                        quote(columnName), quote(tableId), quote(columnName));\n        return jdbc.prepareQueryAndMap(\n                minQuery,\n                ps -> ps.setObject(1, excludedLowerBound),","sourceCodeStart":76,"sourceCodeEnd":112,"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#L76-L112","documentation":"Db2Utils.queryApproximateRowCnt runs a SYSCAT.TABLES row-count query for a table and maps the single-row result. If the ResultSet has no row (the table row is absent from SYSCAT.TABLES), it throws this SQLException. This indicates the catalog lookup returned nothing for the requested schema/table.","triggerScenarios":"Calling queryApproximateRowCnt(jdbc, tableId) for a tableId whose TABSCHEMA/TABNAME row does not exist in SYSCAT.TABLES (typo in table name, wrong case, or table dropped between split enumeration and count).","commonSituations":"Table name casing mismatch (DB2 stores uppercase by default); table dropped concurrently; connector configured for a table not present in the current database.","solutions":["Verify the table exists: SELECT TABSCHEMA, TABNAME FROM SYSCAT.TABLES WHERE TABSCHEMA='<schema>' AND TABNAME='<table>'","Check table-name case in the connector config — DB2 identifiers are usually uppercase","Confirm the connection points to the database that actually contains the table","Re-run the job if the table was dropped/recreated concurrently"],"exampleFix":"// before: tableId built from lowercase config\nTableId.of(\"MYDB\", \"myschema\", \"mytable\");\n// after: normalize to DB2 upper-case identifiers\nTableId.of(\"MYDB\", \"MYSCHEMA\", \"MYTABLE\");","handlingStrategy":"validation","validationCode":"// Pre-check the table exists in DB2 catalog\nSELECT COUNT(*) FROM SYSCAT.TABLES WHERE TABSCHEMA = 'MYSCHEMA' AND TABNAME = 'MYTABLE';","typeGuard":null,"tryCatchPattern":"try { long cnt = Db2Utils.queryApproximateRowCnt(jdbc, tableId); } catch (SQLException e) { if (e.getMessage().contains(\"No result returned\")) { /* fallback: table missing — check name case/schema */ } throw e; }","preventionTips":["Uppercase DB2 identifiers in config","Validate table existence at startup before enabling incremental snapshot","Watch for concurrent DDL/drop during snapshot"],"tags":["db2","cdc","empty-result-set","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-14T11:17:12.474Z"}