forked from sqlancer/sqlancer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDorisDropViewGenerator.java
More file actions
27 lines (22 loc) · 951 Bytes
/
DorisDropViewGenerator.java
File metadata and controls
27 lines (22 loc) · 951 Bytes
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
package sqlancer.doris.gen;
import sqlancer.IgnoreMeException;
import sqlancer.Randomly;
import sqlancer.common.query.SQLQueryAdapter;
import sqlancer.doris.DorisProvider.DorisGlobalState;
public final class DorisDropViewGenerator {
private DorisDropViewGenerator() {
}
public static SQLQueryAdapter dropView(DorisGlobalState globalState) {
if (globalState.getSchema().getTables(t -> t.isView()).size() == 0) {
throw new IgnoreMeException();
}
StringBuilder sb = new StringBuilder("DROP VIEW ");
if (Randomly.getBoolean()) {
sb.append("IF EXISTS ");
}
// TODO: DROP VIEW syntax: DROP MATERIALIZED VIEW [IF EXISTS] mv_name ON table_name;
// should record original table name in view table
sb.append(globalState.getSchema().getRandomTableOrBailout(t -> t.isView()).getName());
return new SQLQueryAdapter(sb.toString(), null, true);
}
}