Skip to content

Commit 407e979

Browse files
author
gituser
committed
Merge branch 'hotfix_1.10_4.0.x_34801' into 1.10_release_4.0.x
2 parents 8ea9191 + e2b3ed1 commit 407e979

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

core/src/main/java/com/dtstack/flink/sql/util/TableUtils.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,11 +539,25 @@ private static void replaceConditionNode(SqlNode selectNode, String oldTbName, S
539539

540540
String tableName = sqlIdentifier.names.asList().get(0);
541541
String tableField = sqlIdentifier.names.asList().get(1);
542-
String fieldKey = tableName + "_" + tableField;
542+
String fieldKey = tableName + "." + tableField;
543543

544544
if(tableName.equalsIgnoreCase(oldTbName)){
545545

546-
String newFieldName = fieldReplaceRef.get(fieldKey) == null ? tableField : fieldReplaceRef.get(fieldKey);
546+
/*
547+
* ****Before replace:*****
548+
* fieldKey: b.department
549+
* fieldReplaceRef : b.department -> a_b_0.department0
550+
* oldFieldRef: a_b_0.department0
551+
* oldTbName: b
552+
* oldFieldName: department
553+
* ****After replace:*****
554+
* newTbName: a_b_0
555+
* newFieldName: department0
556+
*/
557+
String oldFieldRef = fieldReplaceRef.get(fieldKey);
558+
String newFieldName = (oldFieldRef != null && !StringUtils.substringAfter(oldFieldRef, ".").isEmpty()) ?
559+
StringUtils.substringAfter(oldFieldRef, ".") : tableField;
560+
547561
SqlIdentifier newField = ((SqlIdentifier)selectNode).setName(0, newTbName);
548562
newField = newField.setName(1, newFieldName);
549563
((SqlIdentifier)selectNode).assignNamesFrom(newField);

0 commit comments

Comments
 (0)