2222
2323import com .dtstack .flink .sql .util .ClassUtil ;
2424import com .dtstack .flink .sql .util .DtStringUtil ;
25+ import com .google .common .base .Preconditions ;
2526import com .google .common .collect .Lists ;
2627import com .google .common .collect .Maps ;
2728import 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