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 ;
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