{"record":{"id":"0a593ddf8300ebca","repo":"apache/seatunnel","slug":"error-parsing-sql","errorCode":null,"errorMessage":"Error parsing SQL.","messagePattern":"Error parsing SQL\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/source/converter/SqlToPaimonPredicateConverter.java","lineNumber":88,"sourceCode":"import java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Objects;\nimport java.util.Optional;\nimport java.util.regex.Matcher;\nimport java.util.regex.Pattern;\n\npublic class SqlToPaimonPredicateConverter {\n\n    public static PlainSelect convertToPlainSelect(String query) {\n        if (StringUtils.isBlank(query)) {\n            return null;\n        }\n        Statement statement = null;\n        try {\n            statement = CCJSqlParserUtil.parse(query);\n        } catch (JSQLParserException e) {\n            throw new IllegalArgumentException(\"Error parsing SQL.\", e);\n        }\n        // Confirm that the SQL statement is a Select statement\n        if (!(statement instanceof Select)) {\n            throw new IllegalArgumentException(\"Only SELECT statements are supported.\");\n        }\n        Select select = (Select) statement;\n        Select selectBody = select.getSelectBody();\n        if (!(selectBody instanceof PlainSelect)) {\n            throw new IllegalArgumentException(\"Only simple SELECT statements are supported.\");\n        }\n        PlainSelect plainSelect = (PlainSelect) selectBody;\n        if (plainSelect.getHaving() != null\n                || plainSelect.getGroupBy() != null\n                || plainSelect.getOrderByElements() != null\n                || plainSelect.getLimit() != null) {\n            throw new IllegalArgumentException(\n                    \"Only SELECT statements with WHERE clause are supported. The Having, Group By, Order By, Limit clauses are currently unsupported.\");\n        }","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/source/converter/SqlToPaimonPredicateConverter.java#L70-L106","documentation":"SqlToPaimonPredicateConverter.convertToPlainSelect parses the user-supplied predicate SQL with JSqlParser (CCJSqlParserUtil.parse) and wraps JSQLParserException in IllegalArgumentException('Error parsing SQL.'). It throws when the query string is not syntactically valid SQL the parser understands.","triggerScenarios":"Passing a malformed or dialect-specific SQL predicate string (e.g. a Paimon/MySQL-only syntax, unbalanced quotes, missing WHERE, comments JSqlParser can't handle) to the converter used for Paimon source predicate pushdown.","commonSituations":"Users writing filter SQL in a dialect JSqlParser doesn't support (backtick vs double-quote mixing, vendor functions); typos in WHERE clauses; empty or whitespace-only fragments slipping past the earlier isBlank check.","solutions":["Print/inspect the SQL string and validate it is a syntactically correct SELECT","Simplify the predicate to plain standard SQL (column op value with AND/OR)","Quote identifiers the way JSqlParser accepts (double quotes or consistent backticks)","Test the SQL with JSqlParser directly to reproduce and fix the syntax error"],"exampleFix":"// before\nString sql = \"SELECT * FROM t WHERE date > '2024-01-01' AND status in (1,2\")\"; // unbalanced\n// after\nString sql = \"SELECT * FROM t WHERE date > '2024-01-01' AND status IN (1, 2)\";","handlingStrategy":"validation","validationCode":"try { CCJSqlParserUtil.parse(sql); } catch (JSQLParserException e) { throw new IllegalArgumentException(\"Invalid filter SQL: \" + sql, e); }","typeGuard":null,"tryCatchPattern":"try { converter.convertToPlainSelect(query); } catch (IllegalArgumentException e) { if (e.getMessage().equals(\"Error parsing SQL.\")) { log.error(\"Malformed predicate SQL: {}\", query); } throw e; }","preventionTips":["Validate filter SQL with JSqlParser in tests before deploying","Stick to plain standard SQL syntax in predicate strings","Avoid dialect-specific functions and syntax in pushdown filters"],"tags":["sql","parse-error","paimon","predicate-pushdown"],"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-14T05:17:10.506Z"}