-
Notifications
You must be signed in to change notification settings - Fork 397
Expand file tree
/
Copy pathDorisInOperation.java
More file actions
52 lines (44 loc) · 1.68 KB
/
DorisInOperation.java
File metadata and controls
52 lines (44 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package sqlancer.doris.ast;
import java.util.List;
import sqlancer.common.ast.newast.NewInOperatorNode;
import sqlancer.doris.DorisSchema;
public class DorisInOperation extends NewInOperatorNode<DorisExpression> implements DorisExpression {
private final DorisExpression leftExpr;
private final List<DorisExpression> rightExpr;
public DorisInOperation(DorisExpression left, List<DorisExpression> right, boolean isNegated) {
super(left, right, isNegated);
this.leftExpr = left;
this.rightExpr = right;
}
@Override
public DorisSchema.DorisDataType getExpectedType() {
return DorisSchema.DorisDataType.BOOLEAN;
}
@Override
public DorisConstant getExpectedValue() {
DorisConstant leftValue = leftExpr.getExpectedValue();
if (leftValue == null) {
return null;
}
if (leftValue.isNull()) {
return DorisConstant.createNullConstant();
}
boolean containNull = false;
for (DorisExpression expr : rightExpr) {
DorisConstant rightValue = expr.getExpectedValue();
if (rightValue == null) {
return null;
}
if (rightValue.isNull()) {
containNull = true;
} else if (rightValue.valueEquals(leftValue).isBoolean() && rightValue.valueEquals(leftValue).asBoolean()) {
return DorisConstant.createBooleanConstant(!isNegated());
}
}
if (containNull) {
return DorisConstant.createNullConstant();
}
// should return false when not considering isNegated op
return DorisConstant.createBooleanConstant(isNegated());
}
}