jitendrakr88 commented on code in PR #15498: URL: https://github.com/apache/pinot/pull/15498#discussion_r2049668083
########## pinot-common/src/main/java/org/apache/pinot/sql/parsers/ParserUtils.java: ########## @@ -39,6 +39,49 @@ public static void validateFunction(String canonicalName, List<Expression> opera } } + /** + * Sanitize the sql string for parsing by normalizing whitespace which can + * cause performance issues with regex based parsing. + * This method replaces multiple consecutive whitespace characters with a single space. + * + * @param sql The raw SQL string to sanitize. May be null. + * @return A sanitized SQL string with normalized whitespace and no trailing spaces, + * or {@code null} if the input was {@code null}. + */ + public static String sanitizeSqlForParsing(String sql) { + + // 1. Remove excessive whitespace + + int length = sql.length(); + StringBuilder builder = new StringBuilder(length); + boolean inWhitespaceBlock = false; + + for (int charIndex = 0; charIndex < length; charIndex++) { Review Comment: [discussed-offline] Modified to strip the trailing slash only. -- 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