dttung2905 commented on issue #12304:
URL: https://github.com/apache/pinot/issues/12304#issuecomment-1924884957

   Thanks @walterddr for the detailed pointer.
   I take a look at the code and I think `validate` stage might be a good place 
to implement that check, something like 
   ```java
     private SqlNode validate(SqlNode parsed, PlannerContext plannerContext)
         throws Exception {
       // 2. validator to validate.
       SqlNode validated = plannerContext.getValidator().validate(parsed);
       // Check for LIMIT clause in the main query
       if (validated instanceof SqlSelect) {
         SqlSelect sqlSelect = (SqlSelect) validated;
         if (sqlSelect.getFetch() == null) {
           // Add LIMIT 100 clause 
           SqlParserPos originalPos = sqlSelect.getParserPosition();
           SqlNode limitNode = SqlLiteral.createExactNumeric("100", 
originalPos);
           ((SqlSelect) validated).setFetch(limitNode);
         }
       }
       if (null == validated || !validated.getKind().belongsTo(SqlKind.QUERY)) {
         throw new IllegalArgumentException(
             String.format("unsupported SQL query, cannot validate out a valid 
sql from:\n%s", parsed));
       }
       return validated;
     ```
   What do you think about this? Not sure if there are other places to change ( 
probably change test cases too )


-- 
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: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to