apache/seatunnel · error · org.apache.seatunnel.api.table.catalog.exception.CatalogException
execute sql error
Error message
execute sql error
What it means
MaxComputeCatalog.executeSql runs each statement of a multi-statement SQL script through SQLTask.run(...).waitForSuccess(). Any OdpsException from submission or execution is rethrown as CatalogException('execute sql error'). The underlying OdpsException carries the actual ODPS error code.
Source
Thrown at seatunnel-connectors-v2/connector-maxcompute/src/main/java/org/apache/seatunnel/connectors/seatunnel/maxcompute/catalog/MaxComputeCatalog.java:302
public boolean isExistsData(TablePath tablePath) {
throw new UnsupportedOperationException();
}
@Override
public void executeSql(TablePath tablePath, String sql) {
try {
Odps odps = getOdps(tablePath.getDatabaseName(), tablePath.getSchemaName());
String[] sqls = sql.split(";");
for (String s : sqls) {
if (!s.trim().isEmpty()) {
if (!s.trim().endsWith(";")) {
s = s.trim() + ";";
}
SQLTask.run(odps, s).waitForSuccess();
}
}
} catch (OdpsException e) {
throw new CatalogException("execute sql error", e);
}
}
@Override
public PreviewResult previewAction(
ActionType actionType, TablePath tablePath, Optional<CatalogTable> catalogTable) {
if (actionType == ActionType.CREATE_TABLE) {
checkArgument(catalogTable.isPresent(), "CatalogTable cannot be null");
return new SQLPreviewResult(
MaxComputeCatalogUtil.getCreateTableStatement(
readonlyConfig.get(MaxcomputeSinkOptions.SAVE_MODE_CREATE_TEMPLATE),
tablePath,
catalogTable.get()));
} else if (actionType == ActionType.DROP_TABLE) {
return new SQLPreviewResult(MaxComputeCatalogUtil.getDropTableQuery(tablePath, true));
} else {
throw new UnsupportedOperationException("Unsupported action type: " + actionType);
}View on GitHub (pinned to cf67b549a7)
Solutions
- Read the chained OdpsException (getCode/getMessage) for the exact ODPS error
- Run the failing statement manually in MaxCompute Studio/odpscmd to reproduce and fix syntax
- Add IF EXISTS/IF NOT EXISTS guards to DDL or fix the custom template
- Verify endpoint, project name and credentials in the MaxCompute configuration
Defensive patterns
Strategy: try-catch
Validate before calling
for (String s : sql.split(";")) {
if (s.isBlank()) continue;
// dry-run/preview via catalog.previewAction when action type is CREATE_TABLE/DROP_TABLE
} Try / catch
try { catalog.executeSql(tablePath, sql); }
catch (CatalogException e) {
OdpsException oe = (OdpsException) e.getCause();
LOG.error("ODPS task failed code={} msg={}", oe.getCode(), oe.getMessage(), oe);
throw e;
} Prevention
- Preview DDL via previewAction before executing
- Use IF EXISTS / IF NOT EXISTS in custom templates
- Test SQL in odpscmd against the same project/endpoint
- Confirm permissions for all statement types in the script
When it happens
Trigger: Executing save-mode SQL actions (create/drop table, truncate, etc.) where the SQL is invalid, references a missing table/project, or the ODPS task fails at runtime (quota, permission, syntax).
Common situations: Custom save_mode create template with MaxCompute-incompatible DDL; dropping a non-existent table without IF EXISTS; running SQL against the wrong project/endpoint; account lacks permission for the statement.
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
- Check ${databaseName} exist error
- listDatabases exist error
- tableExists${tablePath} error
- create table error
- create partition error
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/0b741f537c2340ef.
Report an issue: GitHub.