forked from sqlancer/sqlancer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDorisColumnValue.java
More file actions
53 lines (43 loc) · 1.52 KB
/
DorisColumnValue.java
File metadata and controls
53 lines (43 loc) · 1.52 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
53
package sqlancer.doris.ast;
import java.util.Objects;
import sqlancer.common.ast.newast.ColumnReferenceNode;
import sqlancer.doris.DorisSchema.DorisColumn;
import sqlancer.doris.DorisSchema.DorisDataType;
public class DorisColumnValue extends ColumnReferenceNode<DorisExpression, DorisColumn> implements DorisExpression {
private final DorisConstant expectedValue;
public DorisColumnValue(DorisColumn column, DorisConstant value) {
super(column);
this.expectedValue = value;
}
@Override
public DorisConstant getExpectedValue() {
return expectedValue;
}
@Override
public DorisDataType getExpectedType() {
return getColumn().getType().getPrimitiveDataType();
}
public static DorisColumnValue create(DorisColumn column, DorisConstant value) {
return new DorisColumnValue(column, value);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
DorisColumnValue that = (DorisColumnValue) o;
if (!this.getColumn().getName().equals(that.getColumn().getName())) {
return false;
}
return Objects.equals(expectedValue, that.expectedValue);
}
@Override
public int hashCode() {
String nameAndValue = this.getColumn().getName();
nameAndValue += expectedValue == null ? "NULL" : expectedValue.toString();
return Objects.hash(nameAndValue);
}
}