Skip to content

Commit b6491d6

Browse files
committed
function field check
1 parent 6e5aebc commit b6491d6

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

@@ -44,6 +45,7 @@ public abstract class AbsTableParser {
4445

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

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

@@ -126,9 +128,12 @@ public void dealPrimaryKey(Matcher matcher, TableInfo tableInfo){
126128
*/
127129
protected void dealNestField(Matcher matcher, TableInfo tableInfo) {
128130
String physicalField = matcher.group(1);
131+
Preconditions.checkArgument(!physicalFieldFunPattern.matcher(physicalField).find(),
132+
"No need to add data types when using functions, The correct way is : strLen(name) as nameSize, ");
133+
129134
String fieldType = matcher.group(3);
130135
String mappingField = matcher.group(4);
131-
Class fieldClass= dbTypeConvertToJavaType(fieldType);
136+
Class fieldClass = dbTypeConvertToJavaType(fieldType);
132137
boolean notNull = matcher.group(5) != null;
133138
TableInfo.FieldExtraInfo fieldExtraInfo = new TableInfo.FieldExtraInfo();
134139
fieldExtraInfo.setNotNull(notNull);

0 commit comments

Comments
 (0)