{"record":{"id":"d17ab8351ad4764e","repo":"apache/seatunnel","slug":"no-result-returned-after-running-query-sqlquery-d17ab8","errorCode":null,"errorMessage":"No result returned after running query [${sqlQuery}]","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/psql/PostgresDialect.java","lineNumber":167,"sourceCode":"                    String.format(\n                            \"SELECT MAX(%s) FROM (\"\n                                    + \"SELECT %s FROM %s WHERE %s >= ? ORDER BY %s ASC LIMIT %s\"\n                                    + \") AS T\",\n                            quotedColumn,\n                            quotedColumn,\n                            tableIdentifier(table.getTablePath()),\n                            quotedColumn,\n                            quotedColumn,\n                            chunkSize);\n        }\n        try (PreparedStatement ps = connection.prepareStatement(sqlQuery)) {\n            ps.setObject(1, includedLowerBound);\n            try (ResultSet rs = ps.executeQuery()) {\n                if (rs.next()) {\n                    return rs.getObject(1);\n                } else {\n                    // this should never happen\n                    throw new SQLException(\n                            String.format(\"No result returned after running query [%s]\", sqlQuery));\n                }\n            }\n        }\n    }\n\n    @Override\n    public Optional<String> getUpsertStatement(\n            String database, String tableName, String[] fieldNames, String[] pkNames) {\n        String uniqueColumns =\n                Arrays.stream(pkNames).map(this::quoteIdentifier).collect(Collectors.joining(\", \"));\n        final Set<String> pkNamesSet = new HashSet<>(Arrays.asList(pkNames));\n        String updateClause =\n                Arrays.stream(fieldNames)\n                        .filter(fieldName -> !pkNamesSet.contains(fieldName))\n                        .map(\n                                fieldName ->\n                                        quoteIdentifier(fieldName)","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/psql/PostgresDialect.java#L149-L185","documentation":"PostgresDialect.queryNextChunkMax executes a single-row MAX(> bound) query to find the upper bound of the next split chunk; if the ResultSet has no row it throws SQLException \"No result returned after running query\". The code comments this 'should never happen' — an aggregate query always returns a row unless the underlying query/connection misbehaves.","triggerScenarios":"Chunk-splitting query on the split column returns an empty ResultSet, e.g. the table/shard vanished mid-scan, the connection points to a different database/node, or the query was altered by an unsupported column type.","commonSituations":"Table dropped or truncated between split enumeration and chunk query; split key column with unusual types causing a malformed predicate; read-replica lag or routing to a different schema (search_path) so the table is not visible.","solutions":["Verify the table still exists and contains data when the split runs","Confirm split_key/column and schema (search_path) resolve to the same table that was enumerated","Check database logs for query errors at that moment","Retry the job if it was a transient concurrent DDL issue"],"exampleFix":"// before\n// table truncated by another job while splitting -> empty result\n// after\n// ensure no concurrent TRUNCATE/DROP during read; or lock/snapshot:\n// SET TRANSACTION SNAPSHOT <snapshot_id>; before chunk queries","handlingStrategy":"retry","validationCode":"// pre-check table visibility and non-emptiness before chunked read\ntry (Statement s = conn.createStatement(); ResultSet r = s.executeQuery(\"SELECT 1 FROM \" + tableId + \" LIMIT 1\")) { if (!r.next()) throw new IllegalStateException(\"table empty/absent\"); }","typeGuard":null,"tryCatchPattern":"try {\n    Object max = dialect.queryNextChunkMax(conn, tableId, column, chunkSize, includedLowerBound);\n} catch (SQLException e) {\n    if (e.getMessage().contains(\"No result returned\")) {\n        // retry with backoff or re-enumerate splits\n    }\n}","preventionTips":["Avoid concurrent TRUNCATE/DROP while a read job is splitting","Ensure schema/search_path consistency across connections","Use appropriate split column types supported by the dialect","Retry transient failures during chunk enumeration"],"tags":["jdbc","postgres","split","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-23T08:17:48.524Z"}