{"record":{"id":"8072ef2684687fa7","repo":"apache/seatunnel","slug":"failed-execute-sql-in-catalog-s","errorCode":null,"errorMessage":"Failed EXECUTE SQL in catalog %s","messagePattern":"Failed EXECUTE SQL in catalog (.+?)","errorType":"exception","errorClass":"CatalogException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/catalog/ClickhouseCatalog.java","lineNumber":178,"sourceCode":"\n    @Override\n    public void truncateTable(TablePath tablePath, boolean ignoreIfNotExists)\n            throws TableNotExistException, CatalogException {\n        try {\n            if (tableExists(tablePath)) {\n                proxy.truncateTable(tablePath, ignoreIfNotExists);\n            }\n        } catch (Exception e) {\n            throw new CatalogException(\"Truncate table failed\", e);\n        }\n    }\n\n    @Override\n    public void executeSql(TablePath tablePath, String sql) {\n        try {\n            proxy.executeSql(sql);\n        } catch (Exception e) {\n            throw new CatalogException(String.format(\"Failed EXECUTE SQL in catalog %s\", sql), e);\n        }\n    }\n\n    @Override\n    public boolean isExistsData(TablePath tablePath) {\n        try {\n            return proxy.isExistsData(tablePath.getFullName());\n        } catch (ExecutionException | InterruptedException e) {\n            throw new RuntimeException(e);\n        }\n    }\n\n    @Override\n    public void createDatabase(TablePath tablePath, boolean ignoreIfExists)\n            throws DatabaseAlreadyExistException, CatalogException {\n        proxy.createDatabase(tablePath.getDatabaseName(), ignoreIfExists);\n    }\n","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/catalog/ClickhouseCatalog.java#L160-L196","documentation":"ClickhouseCatalog.executeSql runs an arbitrary SQL statement against the ClickHouse server through the proxy client. Any failure is wrapped in a CatalogException formatted as 'Failed EXECUTE SQL in catalog <sql>'. Note the message embeds the SQL text, so the failing statement is directly visible in the exception.","triggerScenarios":"Calling executeSql(tablePath, sql) when the SQL is syntactically invalid for ClickHouse, references missing objects, or the user lacks permission; also on connection/timeout failures of the underlying proxy request.","commonSituations":"DDL typed for MySQL/Postgres dialect that ClickHouse rejects; executing ALTER/DROP on tables the user cannot modify; SQL containing unquoted keywords or unsupported functions; server unreachable during DDL.","solutions":["Read the embedded SQL in the message and the 'Caused by' ClickHouse error to fix the statement syntax/dialect","Validate the SQL against ClickHouse syntax (e.g. run it in clickhouse-client) before invoking the catalog","Grant the user the privileges required by the statement, or run as a user with sufficient rights","Confirm server connectivity and retry transient network failures"],"exampleFix":"// before\ncatalog.executeSql(tablePath, \"ALTER TABLE db.t MODIFY COLUMN c1 INT\");\n// after\ncatalog.executeSql(tablePath, \"ALTER TABLE db.t MODIFY COLUMN c1 Int32\"); // ClickHouse dialect","handlingStrategy":"try-catch","validationCode":"// dry-run the statement first\ncatalog.executeSql(tablePath, \"EXPLAIN \" + sql); // throws CatalogException with the SQL text if invalid","typeGuard":null,"tryCatchPattern":"try {\n    catalog.executeSql(tablePath, sql);\n} catch (CatalogException e) {\n    // e.getMessage() already embeds the failing SQL\n    logger.error(\"executeSql failed [{}]: {}\", sql, e.getCause() != null ? e.getCause().getMessage() : e.getMessage());\n    throw e;\n}","preventionTips":["Write ClickHouse-dialect SQL (Int32/String, no MySQL-only clauses) and test it in clickhouse-client first","Dry-run with EXPLAIN when the driver supports it","Grant users the privileges the DDL requires","Keep statements idempotent (IF EXISTS / IF NOT EXISTS) so safe retries are possible"],"tags":["clickhouse","catalog","sql","ddl"],"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"}