apache/seatunnel · error · JdbcConnectorException
COMMON_SQL_OPERATION_FAILED
COMMON_SQL_OPERATION_FAILED
Error message
Sql command:
What it means
After buffering rows as CSV, executeBatch invokes the underlying COPY command via CopyManagerProxy.doCopy. If that reflective call throws (InvocationTargetException, IllegalAccessException) or the CSV buffer cannot be read (IOException), the exception is wrapped in this SQL_OPERATION_FAILED error whose message carries the COPY SQL statement.
Source
Thrown at seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/executor/CopyManagerBatchStatementExecutor.java:185
case ARRAY:
case ROW:
default:
throw new JdbcConnectorException(
CommonErrorCodeDeprecated.UNSUPPORTED_DATA_TYPE,
"Unexpected value: " + seaTunnelDataType);
}
}
return csvRecord;
}
@Override
public void executeBatch() throws SQLException {
try {
this.csvPrinter.flush();
this.copyManagerProxy.doCopy(
copySql, new StringReader(this.csvPrinter.getOut().toString()));
} catch (InvocationTargetException | IllegalAccessException | IOException e) {
throw new JdbcConnectorException(
CommonErrorCodeDeprecated.SQL_OPERATION_FAILED, "Sql command: " + copySql);
} finally {
try {
this.csvPrinter.close();
this.csvPrinter = new CSVPrinter(new StringBuilder(), csvFormat);
} catch (Exception ignore) {
}
}
}
@Override
public void closeStatements() throws SQLException {
this.copyManagerProxy = null;
try {
this.csvPrinter.close();
this.csvPrinter = null;
} catch (Exception ignore) {
}View on GitHub (pinned to cf67b549a7)
Solutions
- Read the cause (InvocationTargetException target) for the real database error; fix the underlying SQL/permission problem.
- Verify the user has COPY privileges on the target table.
- Confirm the copy SQL matches the table's column list and the CSVFormat's delimiter/quote settings.
- Check connection health and retry; increase socket/network timeouts for large batches.
Example fix
// before url = "jdbc:postgresql://host:5432/db" // after: grant COPY rights and verify table columns // GRANT INSERT ON target_table TO etl_user;
Defensive patterns
Strategy: try-catch
Validate before calling
// preflight: verify privileges and table shape
// SELECT has_table_privilege('etl_user','target_table','INSERT'); Try / catch
try {
executor.executeBatch();
} catch (JdbcConnectorException e) {
if (CommonErrorCodeDeprecated.SQL_OPERATION_FAILED.equals(e.getErrorCode()) && e.getCause() instanceof InvocationTargetException) {
Throwable dbErr = e.getCause().getCause();
log.error("COPY failed for sql={}, db error={}", copySql, dbErr.getMessage());
}
throw e;
} Prevention
- Grant INSERT/COPY privileges to the sink user.
- Keep the copy SQL column list in sync with the sink schema.
- Reduce batch size and add retries for transient network failures.
- Log full causes (InvocationTargetException target) to surface the real DB error.
When it happens
Trigger: Calling executeBatch on CopyManagerBatchStatementExecutor when the database rejects the COPY statement (syntax/permissions), the connection is broken, or serialization of the CSV buffer fails.
Common situations: User lacks table COPY privileges on PostgreSQL; the copy SQL template does not match the actual table columns; network drop mid-copy; CSV contains characters that break the configured format.
Understand the failure class
Background: "query failed", "%w: SQL error" — wrapped database query errors in Go libraries explained — this error's family across 3 libraries.
Related errors
- Failed to split chunks for table " + tableId
- Error to discover tables:
- Error to check tables:
- No result returned after running query [%s]
- Unexpected error while connecting to MySQL and looking at GT
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/bc3ae8cbfd3f5748.
Report an issue: GitHub.