{"record":{"id":"47a93b1b14edd6e5","repo":"apache/seatunnel","slug":"sql-operation-failed-47a93b","errorCode":"SQL_OPERATION_FAILED","errorMessage":"Failed to convert ResultSet to SeaTunnelRow: ${e.getMessage()}","messagePattern":"Failed to convert ResultSet to SeaTunnelRow: (.+?)","errorType":"error_code","errorClass":"DatabendConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-databend/src/main/java/org/apache/seatunnel/connectors/seatunnel/databend/util/DatabendUtil.java","lineNumber":166,"sourceCode":"                        log.info(\n                                \"Field {} ({}) [{}]: {} ({})\",\n                                i,\n                                fieldName,\n                                fieldType.getSqlType(),\n                                value,\n                                value.getClass().getSimpleName());\n                    }\n                } catch (SQLException e) {\n                    log.error(\"Error getting field {} ({}): {}\", i, fieldName, e.getMessage());\n                    fields[i] = null;\n                }\n            }\n\n            SeaTunnelRow row = new SeaTunnelRow(fields);\n            return row;\n        } catch (Exception e) {\n            log.error(\"Failed to convert ResultSet to SeaTunnelRow: {}\", e.getMessage());\n            throw new DatabendConnectorException(\n                    DatabendConnectorErrorCode.SQL_OPERATION_FAILED,\n                    \"Failed to convert ResultSet to SeaTunnelRow: \" + e.getMessage(),\n                    e);\n        }\n    }\n\n    private static Object getFieldValue(\n            ResultSet resultSet, int columnIndex, SeaTunnelDataType<?> fieldType)\n            throws SQLException {\n        try {\n            if (fieldType instanceof BasicType) {\n                BasicType basicType = (BasicType) fieldType;\n                switch (basicType.getSqlType()) {\n                    case STRING:\n                        return resultSet.getString(columnIndex);\n                    case INT:\n                        int intValue = resultSet.getInt(columnIndex);\n                        return resultSet.wasNull() ? null : intValue;","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-databend/src/main/java/org/apache/seatunnel/connectors/seatunnel/databend/util/DatabendUtil.java#L148-L184","documentation":"Inside convertToSeaTunnelRow, any exception raised while reading ResultSet columns and building the SeaTunnelRow is caught, logged, and rethrown as DatabendConnectorException with code SQL_OPERATION_FAILED and message 'Failed to convert ResultSet to SeaTunnelRow'. It wraps type-conversion failures, column index/type mismatches, or a closed/ exhausted ResultSet.","triggerScenarios":"A ResultSet column type not mappable to the declared SeaTunnel type (e.g. unsupported SQL type); reading column i beyond available columns; calling getters after the ResultSet was closed or after next() returned false; null handling mismatch with the declared field type.","commonSituations":"Schema drift: the Databend table was altered after the job's row type was derived; custom/complex column types (ARRAY, VARIANT) not supported by the converter; connection dropped mid-result-set streaming.","solutions":["Compare the actual Databend table columns/types with the declared SeaTunnelRowType and re-sync the schema (re-run schema extraction or update the schema config)","Avoid unsupported column types (or cast them to supported types in the query, e.g. TO_VARCHAR(variant_col))","Check the wrapped cause for 'ResultSet closed' or connection errors - if so, fix connection stability rather than the schema","Read the e.getMessage() in the exception/log line to identify the exact column index and conversion that failed"],"exampleFix":"// before\nSELECT id, attrs FROM my_table -- attrs is VARIANT, unsupported\n// after\nSELECT id, TO_JSON(attrs) AS attrs_str FROM my_table -- cast to supported string type","handlingStrategy":"try-catch","validationCode":"// verify table schema matches declared rowType before running\nResultSetMetaData md = resultSet.getMetaData();\nif (md.getColumnCount() != rowType.getFieldNames().length) throw new IllegalStateException(\"Schema drift detected\");","typeGuard":null,"tryCatchPattern":"try { row = DatabendUtil.convertToSeaTunnelRow(rs, rowType); } catch (DatabendConnectorException e) {\n    log.error(\"Row conversion failed: {}\", e.getCause(), e);\n    throw e; // treat as dirty-record or schema-drift failure\n}","preventionTips":["Keep declared SeaTunnelRowType in sync with the live Databend table schema; re-derive schema on table changes","Cast unsupported types (VARIANT, ARRAY) to strings in the SELECT statement","Add dirty-data handling so one bad row does not stop the whole pipeline"],"tags":["databend","jdbc","type-conversion","resultset"],"backgroundTag":"sql-query-failed","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"}