{"record":{"id":"bc0f00c47daf23e1","repo":"apache/seatunnel","slug":"failed-to-parse-select-columns","errorCode":null,"errorMessage":"Failed to parse select columns: ","messagePattern":"Failed to parse select columns: ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-iceberg/src/main/java/org/apache/seatunnel/connectors/seatunnel/iceberg/utils/ExpressionUtils.java","lineNumber":87,"sourceCode":"            new DateTimeFormatterBuilder()\n                    .parseCaseInsensitive()\n                    .append(ISO_LOCAL_DATE)\n                    .appendLiteral(' ')\n                    .append(ISO_LOCAL_TIME)\n                    .toFormatter();\n\n    public static List<String> parseSelectColumns(String selectQuery) {\n        if (StringUtils.isNotBlank(selectQuery)) {\n            try {\n                Statement statement = CCJSqlParserUtil.parse(selectQuery);\n                PlainSelect select = (PlainSelect) statement;\n                if (CollectionUtils.isNotEmpty(select.getSelectItems())) {\n                    return select.getSelectItems().stream()\n                            .map(selectItem -> selectItem.toString())\n                            .collect(Collectors.toList());\n                }\n            } catch (JSQLParserException e) {\n                throw new RuntimeException(\"Failed to parse select columns: \" + e.getMessage());\n            }\n        }\n        return new ArrayList<>();\n    }\n\n    public static Expression parseWhereClauseToIcebergExpression(String selectQuery)\n            throws JSQLParserException {\n        // use the JsqlParser to parse the where clause\n        Statement statement = CCJSqlParserUtil.parse(selectQuery);\n        PlainSelect select = (PlainSelect) statement;\n        return convert(select.getWhere(), null);\n    }\n\n    public static Expression convertDeleteSQL(String sql) throws JSQLParserException {\n        Statement statement = CCJSqlParserUtil.parse(sql);\n        Delete delete = (Delete) statement;\n        return convert(delete.getWhere(), null);\n    }","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-iceberg/src/main/java/org/apache/seatunnel/connectors/seatunnel/iceberg/utils/ExpressionUtils.java#L69-L105","documentation":"ExpressionUtils.parseSelectColumns() parses a SELECT SQL string with JSQLParser to extract select items. If the SQL cannot be parsed (JSQLParserException), it wraps it in a RuntimeException with this message. Typically this is used for delete-SQL conversion, so a malformed query breaks expression translation.","triggerScenarios":"Passing SQL that JSQLParser cannot parse into parseSelectColumns — syntax errors, unsupported SQL dialect constructs, missing clauses, or non-SELECT statements.","commonSituations":"Hand-written delete/select queries with typos; dialect-specific SQL (backticks, functions) unsupported by the bundled JSQLParser version; passing a table name or WHERE-only fragment instead of a full SELECT.","solutions":["Print the wrapped cause (e.getMessage() already includes JSQLParser's error) and fix the SQL syntax","Simplify the query — remove dialect-specific syntax (e.g. functions, comments) that JSQLParser doesn't support","Ensure a valid SELECT statement is passed (SELECT cols FROM table), not a bare column list or WHERE clause","Check the JSQLParser version bundled with the connector supports your SQL constructs; upgrade if needed"],"exampleFix":"// before\nparseSelectColumns(\"FROM my_table\")\n// after\nparseSelectColumns(\"SELECT * FROM my_table\")","handlingStrategy":"validation","validationCode":"// Basic sanity check before invoking the parser\nif (sql == null || !sql.trim().toLowerCase().startsWith(\"select\")) throw new IllegalArgumentException(\"expected a SELECT statement\");","typeGuard":null,"tryCatchPattern":"try { cols = parseSelectColumns(sql); } catch (RuntimeException e) { if (e.getMessage().startsWith(\"Failed to parse select columns\")) { /* fix SQL, log e.getMessage() for parser detail */ } throw e; }","preventionTips":["Validate SQL syntax before passing to expression utilities","Avoid dialect-specific syntax the bundled JSQLParser can't parse","Always pass a complete SELECT statement"],"tags":["sql","parser","iceberg"],"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"}