Skip to content

Commit

Permalink
improve cast expr
Browse files Browse the repository at this point in the history
  • Loading branch information
junwen12221 committed Apr 12, 2021
1 parent 7bff36a commit 4fdfe2b
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions hbt/src/main/java/io/mycat/calcite/SqlImplementor.java
Original file line number Diff line number Diff line change
Expand Up @@ -829,11 +829,22 @@ public SqlNode toSql(RexProgram program, RexNode rex) {
assert nodeList.size() == 1;
return nodeList.get(0);
} else {
if (call.getOperands().size() ==1 && call.getOperands().get(0) instanceof RexDynamicParam){
return nodeList.get(0);
}else {
nodeList.add(dialect.getCastSpec(call.getType()));
if (call.getOperands().size() == 1) {
RexNode rexNode = call.getOperands().get(0);
if(rexNode.getType().getSqlTypeName().getFamily() == call.getType().getSqlTypeName().getFamily()){
return nodeList.get(0);
}
if (rexNode instanceof RexDynamicParam) {
return nodeList.get(0);
}
if (rexNode instanceof RexInputRef) {
return nodeList.get(0);
}
if (rexNode instanceof RexLocalRef) {
return nodeList.get(0);
}
}
nodeList.add(dialect.getCastSpec(call.getType()));
}
}
if (op instanceof SqlBinaryOperator && nodeList.size() > 2) {
Expand Down

0 comments on commit 4fdfe2b

Please sign in to comment.