forked from sqlancer/sqlancer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPostgresWindowFunction.java
More file actions
101 lines (78 loc) · 2.68 KB
/
Copy pathPostgresWindowFunction.java
File metadata and controls
101 lines (78 loc) · 2.68 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package sqlancer.postgres.ast;
import java.util.List;
import sqlancer.postgres.PostgresSchema.PostgresDataType;
public class PostgresWindowFunction implements PostgresExpression {
private final String functionName;
private final List<PostgresExpression> arguments;
private final WindowSpecification windowSpec;
private final PostgresDataType returnType;
public PostgresWindowFunction(String functionName, List<PostgresExpression> arguments,
WindowSpecification windowSpec, PostgresDataType returnType) {
this.functionName = functionName;
this.arguments = arguments;
this.windowSpec = windowSpec;
this.returnType = returnType;
}
public String getFunctionName() {
return functionName;
}
public List<PostgresExpression> getArguments() {
return arguments;
}
public WindowSpecification getWindowSpec() {
return windowSpec;
}
@Override
public PostgresDataType getExpressionType() {
return returnType;
}
public static class WindowSpecification {
private final List<PostgresExpression> partitionBy;
private final List<PostgresOrderByTerm> orderBy;
private final WindowFrame frame;
public WindowSpecification(List<PostgresExpression> partitionBy, List<PostgresOrderByTerm> orderBy,
WindowFrame frame) {
this.partitionBy = partitionBy;
this.orderBy = orderBy;
this.frame = frame;
}
public List<PostgresExpression> getPartitionBy() {
return partitionBy;
}
public List<PostgresOrderByTerm> getOrderBy() {
return orderBy;
}
public WindowFrame getFrame() {
return frame;
}
}
public static class WindowFrame {
public enum FrameType {
ROWS("ROWS"), RANGE("RANGE");
private final String sql;
FrameType(String sql) {
this.sql = sql;
}
public String getSQL() {
return sql;
}
}
private final FrameType type;
private final PostgresExpression startExpr;
private final PostgresExpression endExpr;
public WindowFrame(FrameType type, PostgresExpression startExpr, PostgresExpression endExpr) {
this.type = type;
this.startExpr = startExpr;
this.endExpr = endExpr;
}
public FrameType getType() {
return type;
}
public PostgresExpression getStartExpr() {
return startExpr;
}
public PostgresExpression getEndExpr() {
return endExpr;
}
}
}