{"record":{"id":"1f0a3d2b2c72f020","repo":"apache/seatunnel","slug":"no-result-returned-after-running-query-s-1f0a3d","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-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/mysql/MysqlDialect.java","lineNumber":229,"sourceCode":"                                        .getFullName()\n                                        .equals(table.getTablePath().getFullName()));\n\n        if (useTableStats) {\n            // The statement used to get approximate row count which is less\n            // accurate than COUNT(*), but is more efficient for large table.\n            TablePath tablePath = table.getTablePath();\n            String useDatabaseStatement =\n                    String.format(\"USE %s;\", quoteDatabaseIdentifier(tablePath.getDatabaseName()));\n            String rowCountQuery =\n                    String.format(\"SHOW TABLE STATUS LIKE '%s';\", tablePath.getTableName());\n\n            try (Statement stmt = connection.createStatement()) {\n                log.info(\"Split Chunk, approximateRowCntStatement: {}\", useDatabaseStatement);\n                stmt.execute(useDatabaseStatement);\n                log.info(\"Split Chunk, approximateRowCntStatement: {}\", rowCountQuery);\n                try (ResultSet rs = stmt.executeQuery(rowCountQuery)) {\n                    if (!rs.next() || rs.getMetaData().getColumnCount() < 5) {\n                        throw new SQLException(\n                                String.format(\n                                        \"No result returned after running query [%s]\",\n                                        rowCountQuery));\n                    }\n                    return rs.getLong(5);\n                }\n            }\n        }\n\n        return SQLUtils.countForSubquery(connection, table.getQuery());\n    }\n\n    @Override\n    public StringRangeSplitDecision validateStringRangeSplit(\n            Connection connection, JdbcSourceTable table, String columnName, int sampleSize)\n            throws SQLException {\n        if (table.getTablePath() == null\n                || TablePath.DEFAULT.getFullName().equals(table.getTablePath().getFullName())) {","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/mysql/MysqlDialect.java#L211-L247","documentation":"MysqlDialect.approximateRowCntStatement runs an EXPLAIN-based row-count query (returning at least 5 columns) to estimate table size for chunk splitting. If the ResultSet is empty or has fewer than 5 metadata columns, it throws this SQLException because no reliable row count can be extracted.","triggerScenarios":"Executing the dialect's rowCountQuery (e.g. EXPLAIN SELECT / information_schema query) against a MySQL-compatible database that returns no rows, or whose result shape has fewer than 5 columns — i.e. the statement form is not supported by that server.","commonSituations":"Pointing the MySQL dialect at a non-MySQL backend (early TiDB/OceanBase MySQL-mode versions, cloud MySQL variants) whose EXPLAIN output shape differs; querying a view or temp table where the count query yields no row; server version differences in EXPLAIN format.","solutions":["Verify the target is a genuine MySQL server whose EXPLAIN output includes the rows column (5th column).","Ensure the correct dialect is selected for the actual database (e.g. TiDB/OceanBase dialects) instead of MysqlDialect.","Grant the connection user permission to read the target database/table so the count query returns a row.","Upgrade SeaTunnel connector version if your server's EXPLAIN format changed."],"exampleFix":"// before\nurl=jdbc:mysql://tidb-host:4000/db  (dialect=MySQL)\n// after\nurl=jdbc:mysql://tidb-host:4000/db  (dialect=TiDB, which supports the expected EXPLAIN shape)","handlingStrategy":"validation","validationCode":"// Before job: verify the count query shape\ntry (ResultSet rs = stmt.executeQuery(rowCountQuery)) {\n    if (!rs.next() || rs.getMetaData().getColumnCount() < 5)\n        throw new IllegalStateException(\"Server does not support expected EXPLAIN row-count shape\");\n}","typeGuard":null,"tryCatchPattern":"catch (SQLException e) { if (e.getMessage().contains(\"No result returned\")) { /* fall back to SELECT COUNT(*) or another split strategy */ } }","preventionTips":["Use the dialect matching your actual database (MySQL vs TiDB/OceanBase variants)","Test the EXPLAIN-based count query manually against your server before running chunked reads","Ensure the connection user can read target table metadata"],"tags":["jdbc","mysql","sql","chunk-splitting"],"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"}