{"record":{"id":"0b741f537c2340ef","repo":"apache/seatunnel","slug":"execute-sql-error","errorCode":null,"errorMessage":"execute sql error","messagePattern":"execute sql error","errorType":"exception","errorClass":"org.apache.seatunnel.api.table.catalog.exception.CatalogException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-maxcompute/src/main/java/org/apache/seatunnel/connectors/seatunnel/maxcompute/catalog/MaxComputeCatalog.java","lineNumber":302,"sourceCode":"    public boolean isExistsData(TablePath tablePath) {\n        throw new UnsupportedOperationException();\n    }\n\n    @Override\n    public void executeSql(TablePath tablePath, String sql) {\n        try {\n            Odps odps = getOdps(tablePath.getDatabaseName(), tablePath.getSchemaName());\n            String[] sqls = sql.split(\";\");\n            for (String s : sqls) {\n                if (!s.trim().isEmpty()) {\n                    if (!s.trim().endsWith(\";\")) {\n                        s = s.trim() + \";\";\n                    }\n                    SQLTask.run(odps, s).waitForSuccess();\n                }\n            }\n        } catch (OdpsException e) {\n            throw new CatalogException(\"execute sql error\", e);\n        }\n    }\n\n    @Override\n    public PreviewResult previewAction(\n            ActionType actionType, TablePath tablePath, Optional<CatalogTable> catalogTable) {\n        if (actionType == ActionType.CREATE_TABLE) {\n            checkArgument(catalogTable.isPresent(), \"CatalogTable cannot be null\");\n            return new SQLPreviewResult(\n                    MaxComputeCatalogUtil.getCreateTableStatement(\n                            readonlyConfig.get(MaxcomputeSinkOptions.SAVE_MODE_CREATE_TEMPLATE),\n                            tablePath,\n                            catalogTable.get()));\n        } else if (actionType == ActionType.DROP_TABLE) {\n            return new SQLPreviewResult(MaxComputeCatalogUtil.getDropTableQuery(tablePath, true));\n        } else {\n            throw new UnsupportedOperationException(\"Unsupported action type: \" + actionType);\n        }","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-maxcompute/src/main/java/org/apache/seatunnel/connectors/seatunnel/maxcompute/catalog/MaxComputeCatalog.java#L284-L320","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"for (String s : sql.split(\";\")) {\n    if (s.isBlank()) continue;\n    // dry-run/preview via catalog.previewAction when action type is CREATE_TABLE/DROP_TABLE\n}","typeGuard":null,"tryCatchPattern":"try { catalog.executeSql(tablePath, sql); }\ncatch (CatalogException e) {\n    OdpsException oe = (OdpsException) e.getCause();\n    LOG.error(\"ODPS task failed code={} msg={}\", oe.getCode(), oe.getMessage(), oe);\n    throw e;\n}","preventionTips":["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"],"tags":["maxcompute","catalog","sql","odps"],"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-14T11:17:12.474Z"}