Skip to content

Commit 9ec2f5e

Browse files
committed
Merge branch 'feat_SourceFunctionCheck' into 'v1.8.0_dev'
数据源使用函数的时候校验,改下分支名 See merge request !206
2 parents 011fa58 + b6491d6 commit 9ec2f5e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

core/src/main/java/com/dtstack/flink/sql/table/AbsTableParser.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import com.dtstack.flink.sql.util.ClassUtil;
2424
import com.dtstack.flink.sql.util.DtStringUtil;
25+
import com.google.common.base.Preconditions;
2526
import com.google.common.collect.Lists;
2627
import com.google.common.collect.Maps;
2728
import org.apache.commons.lang3.StringUtils;
@@ -45,6 +46,7 @@ public abstract class AbsTableParser {
4546

4647
private static Pattern primaryKeyPattern = Pattern.compile("(?i)PRIMARY\\s+KEY\\s*\\((.*)\\)");
4748
private static Pattern nestJsonFieldKeyPattern = Pattern.compile("(?i)((@*\\S+\\.)*\\S+)\\s+(\\w+)\\s+AS\\s+(\\w+)(\\s+NOT\\s+NULL)?$");
49+
private static Pattern physicalFieldFunPattern = Pattern.compile("\\w+\\((\\w+)\\)$");
4850

4951
private Map<String, Pattern> patternMap = Maps.newHashMap();
5052

@@ -131,9 +133,12 @@ public void dealPrimaryKey(Matcher matcher, TableInfo tableInfo){
131133
*/
132134
protected void dealNestField(Matcher matcher, TableInfo tableInfo) {
133135
String physicalField = matcher.group(1);
136+
Preconditions.checkArgument(!physicalFieldFunPattern.matcher(physicalField).find(),
137+
"No need to add data types when using functions, The correct way is : strLen(name) as nameSize, ");
138+
134139
String fieldType = matcher.group(3);
135140
String mappingField = matcher.group(4);
136-
Class fieldClass= dbTypeConvertToJavaType(fieldType);
141+
Class fieldClass = dbTypeConvertToJavaType(fieldType);
137142
boolean notNull = matcher.group(5) != null;
138143
TableInfo.FieldExtraInfo fieldExtraInfo = new TableInfo.FieldExtraInfo();
139144
fieldExtraInfo.setNotNull(notNull);

0 commit comments

Comments
 (0)