Skip to content

Commit 1a361e1

Browse files
author
xuchao
committed
修改表名称和 schema 添加引号的逻辑
1 parent b59ef71 commit 1a361e1

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,14 +261,43 @@ public static String firstUpperCase(String str) {
261261
}
262262

263263
public static String getTableFullPath(String schema, String tableName) {
264+
String[] tableInfoSplit = StringUtils.split(tableName, ".");
265+
//表明表信息带了schema
266+
if(tableInfoSplit.length == 2){
267+
schema = tableInfoSplit[0];
268+
tableName = tableInfoSplit[1];
269+
}
270+
271+
//清理首个字符" 和最后字符 "
272+
schema = rmStrQuote(schema);
273+
tableName = rmStrQuote(tableName);
274+
264275
if (StringUtils.isEmpty(schema)){
265276
return addQuoteForStr(tableName);
266277
}
278+
267279
String schemaAndTabName = addQuoteForStr(schema) + "." + addQuoteForStr(tableName);
268280
return schemaAndTabName;
269281
}
270282

283+
/**
284+
* 清理首个字符" 和最后字符 "
285+
*/
286+
public static String rmStrQuote(String str){
287+
if(StringUtils.isEmpty(str)){
288+
return str;
289+
}
290+
291+
if(str.startsWith("\"")){
292+
str = str.substring(1);
293+
}
294+
295+
if(str.endsWith("\"")){
296+
str = str.substring(0, str.length()-1);
297+
}
271298

299+
return str;
300+
}
272301

273302
public static String addQuoteForStr(String column) {
274303
return getStartQuote() + column + getEndQuote();

0 commit comments

Comments
 (0)