@@ -105,7 +105,7 @@ public void exec(String sql, Map<String, SideTableInfo> sideTableMap, StreamTabl
105105 for (FieldReplaceInfo replaceInfo : replaceInfoList ){
106106 fieldNames = Lists .newArrayList ();
107107 replaceFieldName (pollSqlNode , replaceInfo .getMappingTable (), replaceInfo .getTargetTableName (), replaceInfo .getTargetTableAlias ());
108- addAliasForFiledNode (pollSqlNode , fieldNames , replaceInfo .getMappingTable ());
108+ addAliasForFieldNode (pollSqlNode , fieldNames , replaceInfo .getMappingTable ());
109109 }
110110 }
111111
@@ -130,16 +130,16 @@ public void exec(String sql, Map<String, SideTableInfo> sideTableMap, StreamTabl
130130 }
131131
132132
133- private void addAliasForFiledNode (SqlNode pollSqlNode , List <String > fieldList , HashBasedTable <String , String , String > mappingTable ) {
133+ private void addAliasForFieldNode (SqlNode pollSqlNode , List <String > fieldList , HashBasedTable <String , String , String > mappingTable ) {
134134 SqlKind sqlKind = pollSqlNode .getKind ();
135135 switch (sqlKind ) {
136136 case INSERT :
137137 SqlNode source = ((SqlInsert ) pollSqlNode ).getSource ();
138- addAliasForFiledNode (source , fieldList , mappingTable );
138+ addAliasForFieldNode (source , fieldList , mappingTable );
139139 break ;
140140
141141 case AS :
142- addAliasForFiledNode (((SqlBasicCall ) pollSqlNode ).getOperands ()[0 ], fieldList , mappingTable );
142+ addAliasForFieldNode (((SqlBasicCall ) pollSqlNode ).getOperands ()[0 ], fieldList , mappingTable );
143143 break ;
144144
145145 case SELECT :
@@ -152,10 +152,10 @@ private void addAliasForFiledNode(SqlNode pollSqlNode, List<String> fieldList, H
152152 if (sqlIdentifier .names .size () == 1 ) {
153153 return ;
154154 }
155-
156- String filedName = sqlIdentifier .names .get (1 );
157- if (!filedName .endsWith ("0" ) ) {
158- fieldList .add (filedName );
155+ // save real field
156+ String fieldName = sqlIdentifier .names .get (1 );
157+ if (!fieldName .endsWith ("0" ) || fieldName . endsWith ( "0" ) && mappingTable . columnMap (). containsKey ( fieldName ) ) {
158+ fieldList .add (fieldName );
159159 }
160160
161161 }
@@ -170,7 +170,8 @@ private void addAliasForFiledNode(SqlNode pollSqlNode, List<String> fieldList, H
170170 }
171171
172172 String name = sqlIdentifier .names .get (1 );
173- if (name .endsWith ("0" ) && !fieldList .contains (name .substring (0 , name .length () - 1 )) && !mappingTable .columnMap ().containsKey (name )) {
173+ // avoid real field pv0 convert pv
174+ if (name .endsWith ("0" ) && !fieldList .contains (name ) && !fieldList .contains (name .substring (0 , name .length () - 1 ))) {
174175 SqlOperator operator = new SqlAsOperator ();
175176 SqlParserPos sqlParserPos = new SqlParserPos (0 , 0 );
176177
@@ -604,7 +605,7 @@ public void registerTmpTable(CreateTmpTableParser.SqlParserResult result,
604605 for (FieldReplaceInfo replaceInfo : replaceInfoList ) {
605606 fieldNames = Lists .newArrayList ();
606607 replaceFieldName (pollSqlNode , replaceInfo .getMappingTable (), replaceInfo .getTargetTableName (), replaceInfo .getTargetTableAlias ());
607- addAliasForFiledNode (pollSqlNode , fieldNames , replaceInfo .getMappingTable ());
608+ addAliasForFieldNode (pollSqlNode , fieldNames , replaceInfo .getMappingTable ());
608609 }
609610 }
610611
0 commit comments