Skip to content

Commit

Permalink
fix #703
Browse files Browse the repository at this point in the history
  • Loading branch information
junwen12221 committed Jun 15, 2022
1 parent e71d4ee commit 8f45f28
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions hbt/src/main/java/io/mycat/calcite/RelToSqlConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,20 @@ public Result visit(Project e) {
addSelect(selectList, sqlExpr, e.getRowType());
index++;
}
for (Integer dupColumnPo : dupColumnPos) {
String alias = e.getRowType().getFieldList().get(dupColumnPo).getName() + "_" + dupColumnPo;
selectList.set(dupColumnPo,as(SqlLiteral.createNull(SqlParserPos.ZERO),alias));
for (Integer dupColumnIndex : dupColumnPos) {
String alias = e.getRowType().getFieldList().get(dupColumnIndex).getName() + "_" + dupColumnIndex;

SqlNode sqlNode = selectList.get(dupColumnIndex);

if (sqlNode instanceof SqlCall){
SqlCall sqlCall= ((SqlCall) sqlNode);
if(sqlCall.getOperator().kind == SqlKind.AS){
SqlNode argNode = sqlCall.getOperandList().get(0);
selectList.set(dupColumnIndex,as(argNode,alias));
continue;//退出
}
}
selectList.set(dupColumnIndex,as(sqlNode,alias));
}

builder.setSelect(new SqlNodeList(selectList, POS));
Expand Down

0 comments on commit 8f45f28

Please sign in to comment.