|
16 | 16 |
|
17 | 17 | package io.dingodb.expr.runtime.op; |
18 | 18 |
|
| 19 | +import io.dingodb.expr.common.type.DecimalType; |
| 20 | +import io.dingodb.expr.common.type.DoubleType; |
19 | 21 | import io.dingodb.expr.common.type.FloatType; |
20 | 22 | import io.dingodb.expr.common.type.IntType; |
21 | 23 | import io.dingodb.expr.common.type.Type; |
|
27 | 29 | import io.dingodb.expr.runtime.expr.BinaryOpExpr; |
28 | 30 | import io.dingodb.expr.runtime.expr.Expr; |
29 | 31 | import io.dingodb.expr.runtime.expr.Val; |
| 32 | +import io.dingodb.expr.runtime.op.relational.EqOpFactory; |
| 33 | +import io.dingodb.expr.runtime.op.relational.GeOpFactory; |
| 34 | +import io.dingodb.expr.runtime.op.relational.GtOpFactory; |
| 35 | +import io.dingodb.expr.runtime.op.relational.LeOpFactory; |
| 36 | +import io.dingodb.expr.runtime.op.relational.LtOpFactory; |
| 37 | +import io.dingodb.expr.runtime.op.relational.NeOpFactory; |
30 | 38 | import org.checkerframework.checker.nullness.qual.NonNull; |
31 | 39 | import org.checkerframework.checker.nullness.qual.Nullable; |
32 | 40 |
|
@@ -76,13 +84,29 @@ public OpKey bestKeyOf(@NonNull Type @NonNull [] types) { |
76 | 84 | && (op.getOpType() == OpType.ADD || op.getOpType() == OpType.SUB |
77 | 85 | || op.getOpType() == OpType.MUL || op.getOpType() == OpType.DIV)) { |
78 | 86 | needCast = true; |
| 87 | + } else if ( op != null && (op.getOpType() == OpType.GE || op.getOpType() == OpType.GT |
| 88 | + || op.getOpType() == OpType.LE || op.getOpType() == OpType.GT |
| 89 | + || op.getOpType() == OpType.EQ || op.getOpType() == OpType.NE)) { |
| 90 | + if (operand0.getType() instanceof FloatType || operand1.getType() instanceof FloatType) { |
| 91 | + needCast = true; |
| 92 | + } else if (operand0.getType() instanceof DoubleType || operand1.getType() instanceof DoubleType) { |
| 93 | + needCast = true; |
| 94 | + } |
79 | 95 | } |
80 | 96 |
|
81 | 97 | if (op != null && !needCast) { |
82 | 98 | result = op.createExpr(operand0, operand1); |
83 | 99 | } else { |
84 | | - Type[] types; |
85 | | - if (op != null && type0 instanceof IntType && type1 instanceof IntType |
| 100 | + Type[] types = new Type[]{type0, type1}; |
| 101 | + if ( this instanceof LtOpFactory || this instanceof LeOpFactory |
| 102 | + || this instanceof GeOpFactory || this instanceof GtOpFactory |
| 103 | + || this instanceof EqOpFactory || this instanceof NeOpFactory) { |
| 104 | + if (type0 instanceof FloatType || type1 instanceof FloatType) { |
| 105 | + types = new Type[]{Types.DOUBLE, Types.DOUBLE}; |
| 106 | + } else if (type0 instanceof DoubleType || type1 instanceof DoubleType) { |
| 107 | + types = new Type[]{Types.DOUBLE, Types.DOUBLE}; |
| 108 | + } |
| 109 | + } else if (op != null && type0 instanceof IntType && type1 instanceof IntType |
86 | 110 | && (op.getOpType() == OpType.ADD || op.getOpType() == OpType.SUB || op.getOpType() == OpType.MUL)) { |
87 | 111 | types = new Type[]{Types.LONG, Types.LONG}; |
88 | 112 | } else if (op != null && type0 instanceof FloatType && type1 instanceof FloatType |
|
0 commit comments