You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2021/12/03 19:20:26 UTC

[GitHub] [pinot] Jackie-Jiang commented on a change in pull request #7861: added logic to handle semicolon in the query

Jackie-Jiang commented on a change in pull request #7861:
URL: https://github.com/apache/pinot/pull/7861#discussion_r762186564



##########
File path: pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java
##########
@@ -96,8 +96,31 @@ private CalciteSqlParser() {
   private static final Pattern OPTIONS_REGEX_PATTEN =
       Pattern.compile("option\\s*\\(([^\\)]+)\\)", Pattern.CASE_INSENSITIVE);
 
+  /**
+   * Checks for the presence of semicolon in the sql query and modifies the query accordingly
+   *
+   * @param sql sql query
+   * @return sql query without semicolons
+   *
+   */
+  private static String removeTerminatingSemicolon(String sql) {
+    // Check if the query has semicolon
+    int semiColonIndex = sql.lastIndexOf(';');
+    int sqlLength = sql.length();
+    boolean stripSemiColon = semiColonIndex >= 0;
+
+    // check if semicolons are followed by whitespaces, only then termination should be done
+    for (int i = semiColonIndex + 1; i < sqlLength && stripSemiColon; i++) {

Review comment:
       Let's trim the sql first before checking for the last semicolon. This can help remove the unnecessary whitespace from the query, and we can simply check the character at the last index after trimming




-- 
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-unsubscribe@pinot.apache.org

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



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