Skip to content

Commit 96af902

Browse files
author
Manish Soni
committed
updated the logic of semicolon handling in the sql
1 parent a46509d commit 96af902

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,17 +106,13 @@ private CalciteSqlParser() {
106106
private static String removeTerminatingSemicolon(String sql) {
107107
// trim all the leading and trailing whitespaces
108108
sql = sql.trim();
109-
110-
// Check if the query has semicolon
111-
int semiColonIndex = sql.lastIndexOf(';');
112109
int sqlLength = sql.length();
113-
boolean stripSemiColon = semiColonIndex >= 0;
114110

115-
// check if semicolons is followed by whitespaces, only then it needs to be terminated
116-
for (int i = semiColonIndex + 1; i < sqlLength && stripSemiColon; i++) {
117-
stripSemiColon = Character.isWhitespace(sql.charAt(i));
111+
// Terminate the semicolon only if the last character of the query is semicolon
112+
if (sql.charAt(sqlLength - 1) == ';') {
113+
return sql.substring(0, sqlLength - 1);
118114
}
119-
return stripSemiColon ? sql.substring(0, semiColonIndex) : sql;
115+
return sql;
120116
}
121117

122118
public static PinotQuery compileToPinotQuery(String sql)

0 commit comments

Comments
 (0)