You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] JSQLParser Version 5.3: LIMIT with subquery fails: Was expecting: "BY" #2359
Seems to recognize a limit-by expression, although plain-limit
Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token:<EOF>
at line X, column Y.
Was expecting:
"BY"
at app//net.sf.jsqlparser.parser.CCJSqlParser.generateParseException(CCJSqlParser.java:53111)
at app//net.sf.jsqlparser.parser.CCJSqlParser.jj_consume_token(CCJSqlParser.java:52929)
at app//net.sf.jsqlparser.parser.CCJSqlParser.LimitBy(CCJSqlParser.java:16031)
at app//net.sf.jsqlparser.parser.CCJSqlParser.PlainSelect(CCJSqlParser.java:11805)
at app//net.sf.jsqlparser.parser.CCJSqlParser.Select(CCJSqlParser.java:10144)
at app//net.sf.jsqlparser.parser.CCJSqlParser.SelectWithWithItems(CCJSqlParser.java:10108)
at app//net.sf.jsqlparser.parser.CCJSqlParser.SingleStatement(CCJSqlParser.java:503)
at app//net.sf.jsqlparser.parser.CCJSqlParser.Statement(CCJSqlParser.java:413)
SQL Example:
-- self contained / anonymized example
WITH some_table AS (
SELECT1AS some_column, 2AS another_column
), another_table AS (
SELECT'some_value'AS condition_column
)
SELECT some_column
FROM some_table
ORDER BY some_column
-- this kind of limit expression is not supportedLIMIT (SELECTCOUNT(*) FROM another_table WHERE condition_column ='some_value')
-- real world-like rather more complex, should also be supported-- LIMIT GREATEST(0, 100 - (SELECT COUNT(*) FROM another_table WHERE condition_column = 'some_value'))
Activity
manticore-projects commentedon Jan 5, 2026
Thank you for reporting. Somewhere a
LOOKAHEADis too tight, because it works in general:fix: allow scalar subquery as LIMIT row count (#2359) (#2464)