Skip to content

[BUG] JSQLParser Version 4.9,5.3 : SQL Parse ERROR #2257

@Yizhe1208

Description

@Yizhe1208

Issue Title: Parser Error with function(if(xx,xx,xx)) in all versions 4.9-5.3

Description:
The parser fails to handle SQL statements containing aggregate functions with IF expressions (like sum(if()), max(if())). This occurs in all versions from 4.9 to 5.3.

Steps to Reproduce:

  1. Try to parse any of these SQL statements:
SELECT sum(if(column1=2, column1, 0)) FROM tb_a
SELECT max(if(column1=2, column1, 0)) FROM tb_a


Expected Behavior:
The parser should successfully parse these valid SQL expressions containing IF functions within aggregate functions.

Actual Behavior:
Parser throws an exception:

Exception in thread "main" net.sf.jsqlparser.JSQLParserException: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "(" "("
at line 1, column 13.

Was expecting one of:

<ST_SEMICOLON>

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions