apache/seatunnel · error · DatabendConnectorException
SQL_OPERATION_FAILED
SQL_OPERATION_FAILED
Error message
Failed to check if database exists: {e.getMessage()} What it means
DatabendCatalog.databaseExists() inspects database metadata (via JDBC DatabaseMetaData) to test whether a database/schema exists. Any SQLException during that metadata query is wrapped as SQL_OPERATION_FAILED with this message. It is called by listTables, createTable, createDatabase and dropDatabase, so a failure here also blocks those operations.
Source
Thrown at seatunnel-connectors-v2/connector-databend/src/main/java/org/apache/seatunnel/connectors/seatunnel/databend/catalog/DatabendCatalog.java:139
@Override
public String getDefaultDatabase() throws CatalogException {
return defaultDatabase;
}
@Override
public boolean databaseExists(String databaseName) throws CatalogException {
checkOpen();
try (Connection connection = getConnection()) {
try (ResultSet resultSet = connection.getMetaData().getSchemas()) {
while (resultSet.next()) {
String foundDb = resultSet.getString("table_schema");
if (databaseName.equalsIgnoreCase(foundDb)) {
return true;
}
}
}
} catch (SQLException e) {
throw new DatabendConnectorException(
DatabendConnectorErrorCode.SQL_OPERATION_FAILED,
"Failed to check if database exists: " + e.getMessage(),
e);
}
return false;
}
@Override
public List<String> listDatabases() throws CatalogException {
checkOpen();
try (Connection connection = getConnection()) {
List<String> databases = new ArrayList<>();
try (ResultSet resultSet = connection.getMetaData().getSchemas()) {
while (resultSet.next()) {
String databaseName = resultSet.getString("TABLE_SCHEM");
databases.add(databaseName);
}
}View on GitHub (pinned to cf67b549a7)
Solutions
- Inspect the wrapped SQLException message/SQLState to identify the actual server-side or connection problem.
- Verify the catalog connection still works (reopen the catalog or fix credentials/privileges with SHOW GRANTS for the user).
- If the connection went stale, re-open the catalog before retrying the operation.
- Upgrade/align the Databend JDBC driver if metadata calls are known-broken in your driver version.
Defensive patterns
Strategy: try-catch
Validate before calling
// pre-check with a direct query SELECT count(*) FROM information_schema.databases WHERE database_name = 'mydb';
Try / catch
try {
exists = catalog.databaseExists(db);
} catch (DatabendConnectorException e) {
if (e.getErrorCode() == SQL_OPERATION_FAILED) {
log.error("metadata query failed: {}", e.getCause().getMessage());
// reopen catalog or retry with backoff
}
} Prevention
- Keep catalog connections fresh; reopen after long idle periods
- Grant the configured user privileges to list schemas
- Use a JDBC driver version tested against your server version
- Log and inspect SQLState codes to distinguish auth vs network vs SQL errors
When it happens
Trigger: The JDBC metadata query executed inside databaseExists() throws — connection dropped mid-call, insufficient privileges to list schemas, driver-specific metadata quirks, or server-side query errors while fetching the schema list.
Common situations: Stale/timed-out connection after long idle, user lacking privileges to see the target database, Databend driver version with a metadata implementation bug, or network interruption between worker and Databend.
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
- SQL_OPERATION_FAILED
- Failed listing database in catalog %s
- Failed listing database in catalog %s
- Column ${column} not found in table ${schemaAndTableName}
- Failed to query table schema: {}
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/4ae43cdd4df62ffd.
Report an issue: GitHub.