-
Notifications
You must be signed in to change notification settings - Fork 397
Expand file tree
/
Copy pathDatabendCastOperation.java
More file actions
40 lines (33 loc) · 1.2 KB
/
DatabendCastOperation.java
File metadata and controls
40 lines (33 loc) · 1.2 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
package sqlancer.databend.ast;
import sqlancer.common.ast.BinaryOperatorNode;
import sqlancer.common.ast.newast.NewUnaryPostfixOperatorNode;
import sqlancer.databend.DatabendSchema.DatabendCompositeDataType;
import sqlancer.databend.DatabendSchema.DatabendDataType;
public class DatabendCastOperation extends NewUnaryPostfixOperatorNode<DatabendExpression>
implements DatabendExpression {
DatabendDataType type;
public DatabendCastOperation(DatabendExpression expr, DatabendCompositeDataType type) {
super(expr, new BinaryOperatorNode.Operator() {
@Override
public String getTextRepresentation() {
return "::" + type.toString();
}
});
this.type = type.getPrimitiveDataType();
}
DatabendExpression getExpression() {
return (DatabendExpression) getExpr();
}
@Override
public DatabendConstant getExpectedValue() {
DatabendConstant expectedValue = getExpression().getExpectedValue();
if (expectedValue == null) {
return null;
}
return expectedValue.cast(type);
}
@Override
public DatabendDataType getExpectedType() {
return type;
}
}