forked from sqlancer/sqlancer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCockroachDBJoin.java
More file actions
76 lines (58 loc) · 2.17 KB
/
CockroachDBJoin.java
File metadata and controls
76 lines (58 loc) · 2.17 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
65
66
67
68
69
70
71
72
73
74
75
76
package sqlancer.cockroachdb.ast;
import sqlancer.Randomly;
public class CockroachDBJoin implements CockroachDBExpression {
private final CockroachDBExpression leftTable;
private final CockroachDBExpression rightTable;
private final JoinType joinType;
private final CockroachDBExpression onCondition;
private OuterType outerType;
public enum JoinType {
INNER, NATURAL, CROSS, OUTER;
public static JoinType getRandom() {
return Randomly.fromOptions(values());
}
}
public enum OuterType {
FULL, LEFT, RIGHT;
public static OuterType getRandom() {
return Randomly.fromOptions(values());
}
}
public CockroachDBJoin(CockroachDBExpression leftTable, CockroachDBExpression rightTable, JoinType joinType,
CockroachDBExpression whereCondition) {
this.leftTable = leftTable;
this.rightTable = rightTable;
this.joinType = joinType;
this.onCondition = whereCondition;
}
public CockroachDBExpression getLeftTable() {
return leftTable;
}
public CockroachDBExpression getRightTable() {
return rightTable;
}
public JoinType getJoinType() {
return joinType;
}
public CockroachDBExpression getOnCondition() {
return onCondition;
}
public static CockroachDBJoin createNaturalJoin(CockroachDBExpression left, CockroachDBExpression right) {
return new CockroachDBJoin(left, right, JoinType.NATURAL, null);
}
public static CockroachDBJoin createCrossJoin(CockroachDBExpression left, CockroachDBExpression right) {
return new CockroachDBJoin(left, right, JoinType.CROSS, null);
}
public static CockroachDBJoin createOuterJoin(CockroachDBExpression left, CockroachDBExpression right,
OuterType type, CockroachDBExpression onClause) {
CockroachDBJoin join = new CockroachDBJoin(left, right, JoinType.OUTER, onClause);
join.setOuterType(type);
return join;
}
private void setOuterType(OuterType outerType) {
this.outerType = outerType;
}
public OuterType getOuterType() {
return outerType;
}
}