yeqown opened a new issue, #59962: URL: https://github.com/apache/doris/issues/59962
### Search before asking - [x] I had searched in the [issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no similar issues. ### Description ### Feature Description Allow using placeholders (?) in the LIMIT clause of SQL statements, enabling dynamic specification of LIMIT parameters in prepared statements. ### Background Currently, the Doris Nereids parser only allows integer values in the LIMIT clause, as defined in `DorisParser.g4`: ```plain limitClause : (LIMIT limit=INTEGER_VALUE) | (LIMIT limit=INTEGER_VALUE OFFSET offset=INTEGER_VALUE) | (LIMIT offset=INTEGER_VALUE COMMA limit=INTEGER_VALUE) ; ``` This limitation prevents users from writing flexible prepared statements where the LIMIT and OFFSET values need to be dynamically set at execution time, such as: ```sql PREPARE stmt FROM 'SELECT * FROM table LIMIT ? OFFSET ?'; EXECUTE stmt USING 10, 20; ``` now, we got fault: `Error 1105 (HY000): errCode = 2, detailMessage = \nmismatched input 'LIMIT' expecting {<EOF>, ';'`);` ### Use case ```sql -- Basic LIMIT with placeholder PREPARE stmt1 FROM 'SELECT * FROM table LIMIT ?'; EXECUTE stmt1 USING 10; -- LIMIT with OFFSET using placeholders PREPARE stmt2 FROM 'SELECT * FROM table LIMIT ? OFFSET ?'; EXECUTE stmt2 USING 10, 20; -- Alternative LIMIT syntax with placeholders PREPARE stmt3 FROM 'SELECT * FROM table LIMIT ?, ?'; EXECUTE stmt3 USING 20, 10; ``` ### Related issues Not found related issue yet ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
