-
Notifications
You must be signed in to change notification settings - Fork 397
Expand file tree
/
Copy pathDuckDBOracleFactory.java
More file actions
86 lines (79 loc) · 3.67 KB
/
DuckDBOracleFactory.java
File metadata and controls
86 lines (79 loc) · 3.67 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
package sqlancer.duckdb;
import java.sql.SQLException;
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.TLPWhereOracle;
import sqlancer.common.oracle.TestOracle;
import sqlancer.common.query.ExpectedErrors;
import sqlancer.duckdb.gen.DuckDBExpressionGenerator;
import sqlancer.duckdb.test.DuckDBQueryPartitioningAggregateTester;
import sqlancer.duckdb.test.DuckDBQueryPartitioningDistinctTester;
import sqlancer.duckdb.test.DuckDBQueryPartitioningGroupByTester;
import sqlancer.duckdb.test.DuckDBQueryPartitioningHavingTester;
public enum DuckDBOracleFactory implements OracleFactory<DuckDBProvider.DuckDBGlobalState> {
NOREC {
@Override
public TestOracle<DuckDBProvider.DuckDBGlobalState> create(DuckDBProvider.DuckDBGlobalState globalState)
throws SQLException {
DuckDBExpressionGenerator gen = new DuckDBExpressionGenerator(globalState);
ExpectedErrors errors = ExpectedErrors.newErrors().with(DuckDBErrors.getExpressionErrors())
.withRegex(DuckDBErrors.getExpressionErrorsRegex())
.with("canceling statement due to statement timeout").build();
return new NoRECOracle<>(globalState, gen, errors);
}
},
HAVING {
@Override
public TestOracle<DuckDBProvider.DuckDBGlobalState> create(DuckDBProvider.DuckDBGlobalState globalState)
throws SQLException {
return new DuckDBQueryPartitioningHavingTester(globalState);
}
},
WHERE {
@Override
public TestOracle<DuckDBProvider.DuckDBGlobalState> create(DuckDBProvider.DuckDBGlobalState globalState)
throws SQLException {
DuckDBExpressionGenerator gen = new DuckDBExpressionGenerator(globalState);
ExpectedErrors expectedErrors = ExpectedErrors.newErrors().with(DuckDBErrors.getExpressionErrors())
.with(DuckDBErrors.getGroupByErrors()).withRegex(DuckDBErrors.getExpressionErrorsRegex()).build();
return new TLPWhereOracle<>(globalState, gen, expectedErrors);
}
},
GROUP_BY {
@Override
public TestOracle<DuckDBProvider.DuckDBGlobalState> create(DuckDBProvider.DuckDBGlobalState globalState)
throws SQLException {
return new DuckDBQueryPartitioningGroupByTester(globalState);
}
},
AGGREGATE {
@Override
public TestOracle<DuckDBProvider.DuckDBGlobalState> create(DuckDBProvider.DuckDBGlobalState globalState)
throws SQLException {
return new DuckDBQueryPartitioningAggregateTester(globalState);
}
},
DISTINCT {
@Override
public TestOracle<DuckDBProvider.DuckDBGlobalState> create(DuckDBProvider.DuckDBGlobalState globalState)
throws SQLException {
return new DuckDBQueryPartitioningDistinctTester(globalState);
}
},
QUERY_PARTITIONING {
@Override
public TestOracle<DuckDBProvider.DuckDBGlobalState> create(DuckDBProvider.DuckDBGlobalState globalState)
throws Exception {
List<TestOracle<DuckDBProvider.DuckDBGlobalState>> 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<DuckDBProvider.DuckDBGlobalState>(oracles, globalState);
}
};
}