-
Notifications
You must be signed in to change notification settings - Fork 397
Expand file tree
/
Copy pathDorisSelect.java
More file actions
64 lines (51 loc) · 1.99 KB
/
DorisSelect.java
File metadata and controls
64 lines (51 loc) · 1.99 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
54
55
56
57
58
59
60
61
62
63
64
package sqlancer.doris.ast;
import java.util.List;
import java.util.stream.Collectors;
import sqlancer.Randomly;
import sqlancer.common.ast.SelectBase;
import sqlancer.common.ast.newast.Select;
import sqlancer.doris.DorisSchema.DorisColumn;
import sqlancer.doris.DorisSchema.DorisTable;
import sqlancer.doris.visitor.DorisToStringVisitor;
public class DorisSelect extends SelectBase<DorisExpression>
implements DorisExpression, Select<DorisJoin, DorisExpression, DorisTable, DorisColumn> {
public enum DorisSelectDistinctType {
ALL, DISTINCT, DISTINCTROW, NULL;
public static DorisSelectDistinctType getRandomWithoutNull() {
DorisSelectDistinctType sft;
do {
sft = Randomly.fromOptions(values());
} while (sft == DorisSelectDistinctType.NULL);
return sft;
}
}
private DorisSelectDistinctType selectDistinctType = DorisSelectDistinctType.ALL;
public void setDistinct(boolean isDistinct) {
if (isDistinct) {
this.selectDistinctType = DorisSelectDistinctType.DISTINCT;
} else {
this.selectDistinctType = DorisSelectDistinctType.ALL;
}
}
public void setDistinct(DorisSelectDistinctType type) {
this.selectDistinctType = type;
}
public boolean isDistinct() {
return this.selectDistinctType == DorisSelectDistinctType.DISTINCT
|| this.selectDistinctType == DorisSelectDistinctType.DISTINCTROW;
}
@Override
public void setJoinClauses(List<DorisJoin> joinStatements) {
List<DorisExpression> expressions = joinStatements.stream().map(e -> (DorisExpression) e)
.collect(Collectors.toList());
setJoinList(expressions);
}
@Override
public List<DorisJoin> getJoinClauses() {
return getJoinList().stream().map(e -> (DorisJoin) e).collect(Collectors.toList());
}
@Override
public String asString() {
return DorisToStringVisitor.asString(this);
}
}