{"record":{"id":"f82e6034fa994a5d","repo":"apache/seatunnel","slug":"only-support-sql-delete-from-where-not-s","errorCode":null,"errorMessage":"Only support sql: delete from ... where ..., Not support: {}","messagePattern":"Only support sql: delete from \\.\\.\\. where \\.\\.\\., Not support: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-iceberg/src/main/java/org/apache/seatunnel/connectors/seatunnel/iceberg/catalog/IcebergCatalog.java","lineNumber":231,"sourceCode":"            throw new TableNotExistException(\"table not exist\", tablePath);\n        }\n        TableIdentifier icebergTableIdentifier = toIcebergTableIdentifier(tablePath);\n        Snapshot snapshot = catalog.loadTable(icebergTableIdentifier).currentSnapshot();\n        if (snapshot != null) {\n            String total = snapshot.summary().getOrDefault(\"total-records\", null);\n            return total != null && !total.equals(\"0\");\n        }\n        return false;\n    }\n\n    @Override\n    public void executeSql(TablePath tablePath, String sql) {\n        Delete delete;\n        try {\n            Statement statement = CCJSqlParserUtil.parse(sql);\n            delete = (Delete) statement;\n        } catch (Throwable e) {\n            throw new IllegalArgumentException(\n                    \"Only support sql: delete from ... where ..., Not support: \" + sql, e);\n        }\n\n        TablePath targetTablePath = TablePath.of(delete.getTable().getFullyQualifiedName(), false);\n        if (targetTablePath.getDatabaseName() == null) {\n            targetTablePath =\n                    TablePath.of(tablePath.getDatabaseName(), targetTablePath.getTableName());\n        }\n        if (!targetTablePath.equals(tablePath)) {\n            log.warn(\n                    \"The delete table {} is not equal to the target table {}\",\n                    targetTablePath,\n                    tablePath);\n        }\n\n        TableIdentifier icebergTableIdentifier = toIcebergTableIdentifier(targetTablePath);\n        Table table = catalog.loadTable(icebergTableIdentifier);\n        Expression expression = ExpressionUtils.convert(delete.getWhere(), table.schema());","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-iceberg/src/main/java/org/apache/seatunnel/connectors/seatunnel/iceberg/catalog/IcebergCatalog.java#L213-L249","documentation":"IcebergCatalog.executeSql only supports JSqlParser-parseable DELETE FROM ... WHERE statements; any other SQL syntax (or non-DELETE statements) fails to parse or fails the cast to Delete, so an IllegalArgumentException is thrown wrapping the offending SQL.","triggerScenarios":"Calling catalog.executeSql(tablePath, sql) with SQL that is not a DELETE statement (INSERT/UPDATE/SELECT/DDL), or a DELETE whose syntax JSqlParser cannot parse (dialect-specific functions, hints, comments, multi-table deletes).","commonSituations":"Users pass Hive/Spark-dialect DELETE syntax, pass other SQL statements expecting generic SQL execution, or use version-specific parser-incompatible syntax; also common when wiring generic SQL from user config.","solutions":["Rewrite the SQL as a simple 'DELETE FROM <table> WHERE <predicate>' statement.","Use the Iceberg API directly instead of SQL: catalog.loadTable(id).newDelete().deleteFromRowFilter(Expressions.equal(...)).commit()","Use truncateTable() when the intent is deleting all rows.","Pre-validate the SQL shape (starts with 'delete from') before calling executeSql."],"exampleFix":"// before\ncatalog.executeSql(path, \"UPDATE t SET a = 1 WHERE id = 2\");\n// after\ncatalog.executeSql(path, \"DELETE FROM t WHERE id = 2\");","handlingStrategy":"validation","validationCode":"if (sql == null || !sql.trim().toLowerCase().startsWith(\"delete from\")) {\n    throw new IllegalArgumentException(\"executeSql only supports DELETE FROM ... WHERE: \" + sql);\n}","typeGuard":null,"tryCatchPattern":"try { catalog.executeSql(path, sql); } catch (IllegalArgumentException e) { log.error(\"Unsupported SQL: {}\", sql, e); }","preventionTips":["Restrict user-supplied SQL to DELETE statements","Prefer catalog APIs (newDelete/truncateTable) over raw SQL","Document the supported SQL subset for users"],"tags":["iceberg","sql","unsupported-statement","catalog"],"backgroundTag":"unsupported-operation","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}