forked from sqlancer/sqlancer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrestoOracleFactory.java
More file actions
73 lines (67 loc) · 2.79 KB
/
PrestoOracleFactory.java
File metadata and controls
73 lines (67 loc) · 2.79 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
package sqlancer.presto;
import java.util.ArrayList;
import java.util.List;
import sqlancer.OracleFactory;
import sqlancer.common.oracle.CompositeTestOracle;
import sqlancer.common.oracle.NoRECOracle;
import sqlancer.common.oracle.TestOracle;
import sqlancer.common.query.ExpectedErrors;
import sqlancer.presto.gen.PrestoTypedExpressionGenerator;
import sqlancer.presto.test.PrestoQueryPartitioningAggregateTester;
import sqlancer.presto.test.PrestoQueryPartitioningDistinctTester;
import sqlancer.presto.test.PrestoQueryPartitioningGroupByTester;
import sqlancer.presto.test.PrestoQueryPartitioningHavingTester;
import sqlancer.presto.test.PrestoQueryPartitioningWhereTester;
public enum PrestoOracleFactory implements OracleFactory<PrestoGlobalState> {
NOREC {
@Override
public TestOracle<PrestoGlobalState> create(PrestoGlobalState globalState) {
PrestoTypedExpressionGenerator gen = new PrestoTypedExpressionGenerator(globalState);
ExpectedErrors errors = ExpectedErrors.newErrors().with(PrestoErrors.getExpressionErrors())
.with("canceling statement due to statement timeout").build();
return new NoRECOracle<>(globalState, gen, errors);
}
},
HAVING {
@Override
public TestOracle<PrestoGlobalState> create(PrestoGlobalState globalState) {
return new PrestoQueryPartitioningHavingTester(globalState);
}
},
WHERE {
@Override
public TestOracle<PrestoGlobalState> create(PrestoGlobalState globalState) {
return new PrestoQueryPartitioningWhereTester(globalState);
}
},
GROUP_BY {
@Override
public TestOracle<PrestoGlobalState> create(PrestoGlobalState globalState) {
return new PrestoQueryPartitioningGroupByTester(globalState);
}
},
AGGREGATE {
@Override
public TestOracle<PrestoGlobalState> create(PrestoGlobalState globalState) {
return new PrestoQueryPartitioningAggregateTester(globalState);
}
},
DISTINCT {
@Override
public TestOracle<PrestoGlobalState> create(PrestoGlobalState globalState) {
return new PrestoQueryPartitioningDistinctTester(globalState);
}
},
QUERY_PARTITIONING {
@Override
public TestOracle<PrestoGlobalState> create(PrestoGlobalState globalState) throws Exception {
List<TestOracle<PrestoGlobalState>> oracles = new ArrayList<>();
oracles.add(WHERE.create(globalState));
oracles.add(HAVING.create(globalState));
oracles.add(AGGREGATE.create(globalState));
oracles.add(DISTINCT.create(globalState));
oracles.add(GROUP_BY.create(globalState));
return new CompositeTestOracle<>(oracles, globalState);
}
}
}