-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIRISCommon.java
More file actions
52 lines (45 loc) · 1.32 KB
/
IRISCommon.java
File metadata and controls
52 lines (45 loc) · 1.32 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
package sqlancer.iris.gen;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
import sqlancer.Randomly;
import sqlancer.iris.IRISSchema.IRISDataType;
public final class IRISCommon {
private IRISCommon() {
}
public static void appendDataType(IRISDataType type, StringBuilder sb, List<String> opClasses) {
switch (type) {
case VARCHAR:
if (Randomly.getBoolean()) {
sb.append("VAR");
}
sb.append("CHAR");
sb.append("(");
sb.append(ThreadLocalRandom.current().nextInt(1, 500));
sb.append(")");
if (Randomly.getBooleanWithSmallProbability()) {
sb.append(" COLLATE ");
sb.append(Randomly.fromList(opClasses));
}
break;
case DECIMAL:
case NUMERIC:
sb.append(Randomly.fromOptions("NUMERIC", "DECIMAL"));
sb.append("(");
int precision = ThreadLocalRandom.current().nextInt(1, 38);
sb.append(precision);
sb.append(", ");
int scale = ThreadLocalRandom.current().nextInt(0, precision);
sb.append(scale);
sb.append(")");
break;
case DOUBLE:
case FLOAT:
case REAL:
sb.append(Randomly.fromOptions("FLOAT", "REAL", "DOUBLE"));
break;
default:
sb.append(type.name());
break;
}
}
}