-
Notifications
You must be signed in to change notification settings - Fork 397
Expand file tree
/
Copy pathClickHouseConstant.java
More file actions
44 lines (30 loc) · 1.38 KB
/
ClickHouseConstant.java
File metadata and controls
44 lines (30 loc) · 1.38 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
package sqlancer.clickhouse.ast;
import com.clickhouse.client.ClickHouseDataType;
import sqlancer.clickhouse.ast.constant.ClickHouseCreateConstant;
public abstract class ClickHouseConstant extends ClickHouseExpression {
public abstract boolean isNull();
public abstract ClickHouseConstant cast(ClickHouseDataType type);
public abstract boolean asBooleanNotNull();
public abstract ClickHouseDataType getDataType();
public abstract boolean compareInternal(Object value);
public ClickHouseConstant applyEquals(ClickHouseConstant right) {
if (this.getDataType() == right.getDataType()) {
return this.compareInternal(right.getValue()) ? ClickHouseCreateConstant.createTrue()
: ClickHouseCreateConstant.createFalse();
} else {
ClickHouseConstant converted = right.cast(this.getDataType());
return this.applyEquals(converted);
}
}
public abstract ClickHouseConstant applyLess(ClickHouseConstant right);
public abstract Object getValue();
public long asInt() {
throw new UnsupportedOperationException(this.getDataType().toString());
}
public double asDouble() {
throw new UnsupportedOperationException(this.getDataType().toString());
}
public String asString() {
throw new UnsupportedOperationException(this.getDataType().toString());
}
}