Skip to content

Commit

Permalink
fix 别名join异常
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhu4680 committed Apr 21, 2020
1 parent 83429b2 commit 6f8c9aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void parseSelectFields(JoinInfo joinInfo){
if(fieldInfo.getTable().equalsIgnoreCase(sideTableName)){
String sideFieldName = sideTableInfo.getPhysicalFields().getOrDefault(fieldInfo.getFieldName(), fieldInfo.getFieldName());
fields.add(sideFieldName);
sideSelectFieldsType.put(sideTableFieldIndex, getTargetFieldType(sideFieldName));
sideSelectFieldsType.put(sideTableFieldIndex, getTargetFieldType(fieldInfo.getFieldName()));
sideFieldIndex.put(i, sideTableFieldIndex);
sideFieldNameIndex.put(i, sideFieldName);
sideTableFieldIndex++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

package com.dtstack.flink.sql.side.rdb.async;

import org.apache.flink.api.java.typeutils.RowTypeInfo;

import com.dtstack.flink.sql.side.FieldInfo;
import com.dtstack.flink.sql.side.JoinInfo;
import com.dtstack.flink.sql.side.PredicateInfo;
Expand All @@ -33,9 +31,11 @@
import org.apache.calcite.sql.SqlKind;
import org.apache.calcite.sql.SqlNode;
import org.apache.commons.lang3.StringUtils;
import org.apache.flink.api.java.typeutils.RowTypeInfo;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;


Expand Down Expand Up @@ -86,6 +86,7 @@ public void dealOneEqualCon(SqlNode sqlNode, String sideTableName) {

SqlIdentifier left = (SqlIdentifier) ((SqlBasicCall) sqlNode).getOperands()[0];
SqlIdentifier right = (SqlIdentifier) ((SqlBasicCall) sqlNode).getOperands()[1];
Map<String, String> physicalFields = sideTableInfo.getPhysicalFields();

String leftTableName = left.getComponent(0).getSimple();
String leftField = left.getComponent(1).getSimple();
Expand All @@ -94,7 +95,7 @@ public void dealOneEqualCon(SqlNode sqlNode, String sideTableName) {
String rightField = right.getComponent(1).getSimple();

if (leftTableName.equalsIgnoreCase(sideTableName)) {
equalFieldList.add(leftField);
equalFieldList.add(physicalFields.get(leftField));
int equalFieldIndex = -1;
for (int i = 0; i < rowTypeInfo.getFieldNames().length; i++) {
String fieldName = rowTypeInfo.getFieldNames()[i];
Expand All @@ -110,7 +111,7 @@ public void dealOneEqualCon(SqlNode sqlNode, String sideTableName) {

} else if (rightTableName.equalsIgnoreCase(sideTableName)) {

equalFieldList.add(rightField);
equalFieldList.add(physicalFields.get(rightField));
int equalFieldIndex = -1;
for (int i = 0; i < rowTypeInfo.getFieldNames().length; i++) {
String fieldName = rowTypeInfo.getFieldNames()[i];
Expand Down

0 comments on commit 6f8c9aa

Please sign in to comment.