Skip to content

Commit 7d3a9a5

Browse files
committed
fix const join side table as parse error
1 parent 300b470 commit 7d3a9a5

2 files changed

Lines changed: 25 additions & 8 deletions

File tree

core/src/main/java/com/dtstack/flink/sql/side/BaseSideInfo.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,15 @@ public abstract class BaseSideInfo implements Serializable{
7575

7676
protected AbstractSideCache sideCache;
7777

78+
protected JoinInfo joinInfo;
79+
7880
public BaseSideInfo(RowTypeInfo rowTypeInfo, JoinInfo joinInfo, List<FieldInfo> outFieldInfoList,
7981
AbstractSideTableInfo sideTableInfo){
8082
this.rowTypeInfo = rowTypeInfo;
8183
this.outFieldInfoList = outFieldInfoList;
8284
this.joinType = joinInfo.getJoinType();
8385
this.sideTableInfo = sideTableInfo;
86+
this.joinInfo = joinInfo;
8487
parseSelectFields(joinInfo);
8588
buildEqualInfo(joinInfo, sideTableInfo);
8689
}
@@ -178,9 +181,7 @@ private void evalEquation(SqlIdentifier left, SqlIdentifier right, String sideTa
178181
*/
179182
private void evalConstantEquation(SqlLiteral literal, SqlIdentifier identifier) {
180183
String tableName = identifier.getComponent(0).getSimple();
181-
String sideTableName = sideTableInfo.getName();
182-
String errorMsg = "only support set side table constant field, error field " + identifier;
183-
Preconditions.checkState(tableName.equals(sideTableName), errorMsg);
184+
checkSupport(identifier);
184185
String fieldName = identifier.getComponent(1).getSimple();
185186
Object constant = literal.getValue();
186187
List<PredicateInfo> predicateInfos = sideTableInfo.getPredicateInfoes();
@@ -194,6 +195,22 @@ private void evalConstantEquation(SqlLiteral literal, SqlIdentifier identifier)
194195
predicateInfos.add(predicate);
195196
}
196197

198+
private void checkSupport(SqlIdentifier identifier) {
199+
String tableName = identifier.getComponent(0).getSimple();
200+
String sideTableName;
201+
String sideTableAlias;
202+
if (joinInfo.isLeftIsSideTable()) {
203+
sideTableName = joinInfo.getLeftTableName();
204+
sideTableAlias = joinInfo.getLeftTableAlias();
205+
} else {
206+
sideTableName = joinInfo.getRightTableName();
207+
sideTableAlias = joinInfo.getRightTableAlias();
208+
}
209+
boolean isSide = tableName.equals(sideTableName) || tableName.equals(sideTableAlias);
210+
String errorMsg = "only support set side table constant field, error field " + identifier;
211+
Preconditions.checkState(isSide, errorMsg);
212+
}
213+
197214
private void associateField(String sourceTableField, String sideTableField, SqlNode sqlNode) {
198215
String errorMsg = "can't deal equal field: " + sqlNode;
199216
equalFieldList.add(sideTableField);

core/src/main/java/com/dtstack/flink/sql/side/JoinInfo.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ public class JoinInfo implements Serializable {
5555

5656
private String rightTableAlias;
5757

58-
private SqlNode leftNode;
58+
private transient SqlNode leftNode;
5959

60-
private SqlNode rightNode;
60+
private transient SqlNode rightNode;
6161

62-
private SqlNode condition;
62+
private transient SqlNode condition;
6363

64-
private SqlNode selectFields;
64+
private transient SqlNode selectFields;
6565

66-
private SqlNode selectNode;
66+
private transient SqlNode selectNode;
6767

6868
private JoinType joinType;
6969

0 commit comments

Comments
 (0)