Skip to content

Commit edd503a

Browse files
committed
merge release to hotfix
2 parents 85e2d8d + 014c3d9 commit edd503a

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

core/src/main/java/com/dtstack/flink/sql/parser/SqlParser.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import com.google.common.collect.Lists;
2929
import com.google.common.base.Strings;
3030

31-
import java.util.ArrayList;
3231
import java.util.List;
3332
import java.util.Set;
3433
import java.util.regex.Matcher;
@@ -54,7 +53,7 @@ public static void setLocalSqlPluginRoot(String localSqlPluginRoot){
5453
LOCAL_SQL_PLUGIN_ROOT = localSqlPluginRoot;
5554
}
5655

57-
private static final Pattern ADD_FIlE_PATTERN = Pattern.compile("(?i).*add\\s+file\\s+.+");
56+
private static final Pattern ADD_FILE_AND_JAR_PATTERN = Pattern.compile("(?i).*add\\s+file\\s+.+|(?i).*add\\s+jar\\s+.+");
5857

5958
/**
6059
* flink support sql syntax
@@ -75,7 +74,7 @@ public static SqlTree parseSql(String sql, String pluginLoadMode) throws Excepti
7574
.replace("\t", " ").trim();
7675

7776
List<String> sqlArr = DtStringUtil.splitIgnoreQuota(sql, SQL_DELIMITER);
78-
sqlArr = removeAddFileStmt(sqlArr);
77+
sqlArr = removeAddFileAndJarStmt(sqlArr);
7978
SqlTree sqlTree = new SqlTree();
8079
AbstractTableInfoParser tableInfoParser = new AbstractTableInfoParser();
8180
for(String childSql : sqlArr){
@@ -158,12 +157,12 @@ public static SqlTree parseSql(String sql, String pluginLoadMode) throws Excepti
158157
}
159158

160159
/**
161-
* remove add file with statment etc. add file /etc/krb5.conf;
160+
* remove add file and jar with statment etc. add file /etc/krb5.conf, add jar xxx.jar;
162161
*/
163-
private static List<String> removeAddFileStmt(List<String> stmts) {
164-
List<String> cleanedStmts = new ArrayList<>();
162+
private static List<String> removeAddFileAndJarStmt(List<String> stmts) {
163+
List<String> cleanedStmts = Lists.newArrayList();
165164
for (String stmt : stmts) {
166-
Matcher matcher = ADD_FIlE_PATTERN.matcher(stmt);
165+
Matcher matcher = ADD_FILE_AND_JAR_PATTERN.matcher(stmt);
167166
if(!matcher.matches()) {
168167
cleanedStmts.add(stmt);
169168
}

core/src/main/java/com/dtstack/flink/sql/util/DtStringUtil.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,26 +167,20 @@ public static String replaceIgnoreQuota(String str, String oriStr, String replac
167167
public static String dealSqlComment(String sql) {
168168
boolean inQuotes = false;
169169
boolean inSingleQuotes = false;
170-
int bracketLeftNum = 0;
171170
StringBuilder b = new StringBuilder(sql.length());
172171
char[] chars = sql.toCharArray();
173172
for (int index = 0; index < chars.length; index ++) {
174-
if (index == chars.length) {
175-
return b.toString();
176-
}
177173
StringBuilder tempSb = new StringBuilder(2);
178-
if (index > 1) {
174+
if (index >= 1) {
179175
tempSb.append(chars[index - 1]);
180176
tempSb.append(chars[index]);
181177
}
182178

183-
if (tempSb.toString().equals("--")) {
179+
if ("--".equals(tempSb.toString())) {
184180
if (inQuotes) {
185181
b.append(chars[index]);
186182
} else if (inSingleQuotes) {
187183
b.append(chars[index]);
188-
} else if (bracketLeftNum > 0) {
189-
b.append(chars[index]);
190184
} else {
191185
b.deleteCharAt(b.length() - 1);
192186
while (chars[index] != '\n') {

0 commit comments

Comments
 (0)