-
Notifications
You must be signed in to change notification settings - Fork 397
Expand file tree
/
Copy pathPrestoErrors.java
More file actions
188 lines (152 loc) · 7.81 KB
/
PrestoErrors.java
File metadata and controls
188 lines (152 loc) · 7.81 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
package sqlancer.presto;
import java.util.ArrayList;
import java.util.List;
import sqlancer.common.query.ExpectedErrors;
public final class PrestoErrors {
private PrestoErrors() {
}
public static List<String> getExpressionErrors() {
ArrayList<String> errors = new ArrayList<>();
errors.addAll(getFunctionErrors());
// Presto errors
errors.add("cannot be applied to");
errors.add("LIKE expression must evaluate to a varchar");
errors.add("JOIN ON clause must evaluate to a boolean");
// errors.add("Unexpected parameters");
// SELECT SUM(count) FROM (SELECT
// CAST((-179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0000
// IS NOT NULL AND
// -179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0000)
// AS BIGINT)as count FROM t0) as res
errors.add("Decimal overflow");
errors.add("long overflow");
errors.add("multiplication overflow");
errors.add("addition overflow");
errors.add("subtraction overflow");
// cast
// errors.add("Cannot cast");
errors.add("Value cannot be cast to");
errors.add("Cannot cast DECIMAL");
errors.add("Cannot cast BIGINT");
errors.add("Cannot cast INTEGER");
// TODO: check
errors.add("io.airlift.slice.Slice cannot be cast to java.lang.Number");
errors.add("class io.airlift.slice.Slice cannot be cast to class java.lang.Number");
if (PrestoBugs.bug23324) {
errors.add("Cannot cast java.lang.Long to io.airlift.slice.Slice");
}
errors.add("Cannot cast java.lang.String to java.util.List");
errors.add("Unexpected subquery expression in logical plan");
// 9223372036854775808
errors.add("Invalid numeric literal");
errors.add("Division by zero");
errors.add("/ by zero");
errors.add("Cannot subtract hour, minutes or seconds from a date");
errors.add("Cannot add hour, minutes or seconds to a date");
errors.add("DECIMAL scale must be in range");
errors.add("IN value and list items must be the same type");
errors.add("is not a valid timestamp literal");
errors.add("Unknown time-zone ID");
errors.add("GROUP BY position");
// ARRAY
errors.add("Unknown type: ARRAY");
// SELECT
errors.add("WHERE clause must evaluate to a boolean");
errors.add("HAVING clause must evaluate to a boolean");
errors.add("not yet implemented");
errors.add("Value expression and result of subquery must be of the same type for quantified comparison");
errors.add("All IN list values must be the same type");
errors.add("All CASE results must be the same type");
errors.add("Mismatched types");
errors.add("CASE operand type does not match WHEN clause operand type");
errors.add("Subquery result type must be orderable");
errors.add("Escape character must be followed by '%', '_' or the escape character itself");
errors.add("Types are not comparable with NULLIF");
errors.add("not of the same type");
if (PrestoBugs.bug23613) {
errors.add("at index 1");
}
return errors;
}
public static void addExpressionErrors(ExpectedErrors errors) {
errors.addAll(getExpressionErrors());
}
private static List<String> getRegexErrors() {
ArrayList<String> errors = new ArrayList<>();
errors.add("missing ]");
errors.add("missing )");
errors.add("invalid escape sequence");
errors.add("no argument for repetition operator: ");
errors.add("bad repetition operator");
errors.add("trailing \\");
errors.add("invalid perl operator");
errors.add("invalid character class range");
errors.add("width is not integer");
return errors;
}
private static List<String> getFunctionErrors() {
ArrayList<String> errors = new ArrayList<>();
errors.add("SUBSTRING cannot handle negative lengths");
errors.add("is undefined outside [-1,1]"); // ACOS etc
errors.add("invalid type specifier"); // PRINTF
errors.add("argument index out of range"); // PRINTF
errors.add("invalid format string"); // PRINTF
errors.add("number is too big"); // PRINTF
errors.add("Like pattern must not end with escape character!"); // LIKE
errors.add("Could not choose a best candidate function for the function call \"date_part"); // date_part
errors.add("extract specifier"); // date_part
errors.add("not recognized"); // date_part
errors.add("not supported"); // date_part
errors.add("Failed to cast");
errors.add("Conversion Error");
errors.add("Could not cast value");
errors.add("Insufficient padding in RPAD"); // RPAD
errors.add("Could not choose a best candidate function for the function call"); // monthname
errors.add("expected a numeric precision field"); // ROUND
errors.add("with non-constant precision is not supported"); // ROUND
errors.add("Unexpected parameters");
errors.add("not registered");
errors.add("Expected: least(E) E:orderable");
errors.add("Expected: greatest(E) E:orderable");
errors.add("Expected: max_by(V, K) K:orderable, V, max_by(V, K, bigint) V, K:orderable");
errors.add("Expected: min_by(V, K) K:orderable, V, min_by(V, K, bigint) V, K:orderable");
return errors;
}
// TODO: cover presto error
public static List<String> getInsertErrors() {
ArrayList<String> errors = new ArrayList<>();
errors.addAll(getRegexErrors());
errors.addAll(getExpressionErrors());
errors.add("NOT NULL constraint failed");
errors.add("PRIMARY KEY or UNIQUE constraint violated");
errors.add("duplicate key");
errors.add("can't be cast because the value is out of range for the destination type");
errors.add("Could not convert string");
errors.add("Unimplemented type for cast");
errors.add("field value out of range");
errors.add("CHECK constraint failed");
errors.add("Cannot explicitly insert values into rowid column"); // TODO: don't insert into rowid
errors.add(" Column with name rowid does not exist!"); // currently, there doesn't seem to way to determine if
// the table has a primary key
errors.add("Could not cast value");
errors.add("create unique index, table contains duplicate data");
errors.add("Failed to cast");
errors.add("Values rows have mismatched types");
errors.add("Mismatch at column");
errors.add("This connector does not support updates or deletes");
errors.add("Values rows have mismatched types");
errors.add("Invalid numeric literal");
return errors;
}
public static void addInsertErrors(ExpectedErrors errors) {
errors.addAll(getInsertErrors());
}
public static List<String> getGroupByErrors() {
ArrayList<String> errors = new ArrayList<>();
errors.add("must be an aggregate expression or appear in GROUP BY clause");
return errors;
}
public static void addGroupByErrors(ExpectedErrors errors) {
errors.addAll(getGroupByErrors());
}
}