Skip to content

Commit 9af1567

Browse files
authored
Add ClickBench IT Suite (opensearch-project#3860)
* Add clickbench IT Suite Signed-off-by: Lantao Jin <ltjin@amazon.com> * Add original SQL and fix the bug of Sarg point (q41) Signed-off-by: Lantao Jin <ltjin@amazon.com> * fix IT of Sarg related Signed-off-by: Lantao Jin <ltjin@amazon.com> * Fix UT Signed-off-by: Lantao Jin <ltjin@amazon.com> --------- Signed-off-by: Lantao Jin <ltjin@amazon.com>
1 parent 81d3741 commit 9af1567

58 files changed

Lines changed: 962 additions & 109 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

integ-test/src/test/java/org/opensearch/sql/calcite/big5/CalcitePPLBig5IT.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,11 @@
1010

1111
@FixMethodOrder(MethodSorters.JVM)
1212
public class CalcitePPLBig5IT extends PPLBig5IT {
13-
private boolean initialized = false;
1413

1514
@Override
1615
public void init() throws Exception {
1716
super.init();
1817
enableCalcite();
1918
disallowCalciteFallback();
20-
// warm-up
21-
if (!initialized) {
22-
executeQuery("source=big5 | join on 1=1 big5"); // trigger non-pushdown
23-
initialized = true;
24-
}
2519
}
2620
}

integ-test/src/test/java/org/opensearch/sql/calcite/big5/PPLBig5IT.java

Lines changed: 54 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -6,312 +6,300 @@
66
package org.opensearch.sql.calcite.big5;
77

88
import java.io.IOException;
9-
import java.util.LinkedHashMap;
109
import java.util.Locale;
1110
import java.util.Map;
1211
import org.junit.AfterClass;
1312
import org.junit.FixMethodOrder;
14-
import org.junit.Ignore;
1513
import org.junit.Test;
1614
import org.junit.runners.MethodSorters;
15+
import org.opensearch.common.collect.MapBuilder;
1716
import org.opensearch.sql.ppl.PPLIntegTestCase;
1817

1918
@FixMethodOrder(MethodSorters.JVM)
2019
public class PPLBig5IT extends PPLIntegTestCase {
21-
private boolean initialized = false;
22-
private static final Map<String, Long> summary = new LinkedHashMap<>();
20+
private static final MapBuilder<String, Long> summary = MapBuilder.newMapBuilder();
2321

2422
@Override
2523
public void init() throws Exception {
2624
super.init();
2725
loadIndex(Index.BIG5);
2826
disableCalcite();
29-
// warm-up
30-
if (!initialized) {
31-
executeQuery("source=big5 | eval a = 1"); // trigger non-pushdown
32-
initialized = true;
33-
}
3427
}
3528

3629
@AfterClass
3730
public static void reset() throws IOException {
3831
long total = 0;
39-
for (long duration : summary.values()) {
32+
Map<String, Long> map = summary.immutableMap();
33+
for (long duration : map.values()) {
4034
total += duration;
4135
}
4236
System.out.println("Summary:");
43-
for (Map.Entry<String, Long> entry : summary.entrySet()) {
44-
System.out.printf(Locale.ENGLISH, "%s: %d ms%n", entry.getKey(), entry.getValue());
45-
}
37+
map.entrySet().stream()
38+
.sorted(Map.Entry.comparingByKey())
39+
.forEach(
40+
entry ->
41+
System.out.printf(Locale.ENGLISH, "%s: %d ms%n", entry.getKey(), entry.getValue()));
4642
System.out.printf(
4743
Locale.ENGLISH,
4844
"Total %d queries succeed. Average duration: %d ms%n",
49-
summary.size(),
50-
total / summary.size());
45+
map.size(),
46+
total / map.size());
5147
System.out.println();
52-
summary.clear();
53-
}
54-
55-
protected void timing(String query, String ppl) throws IOException {
56-
long start = System.currentTimeMillis();
57-
executeQuery(ppl);
58-
long duration = System.currentTimeMillis() - start;
59-
summary.put(query, duration);
6048
}
6149

6250
@Test
6351
public void asc_sort_timestamp() throws IOException {
6452
String ppl = sanitize(loadFromFile("big5/queries/asc_sort_timestamp.ppl"));
65-
timing("asc_sort_timestamp", ppl);
53+
timing(summary, "asc_sort_timestamp", ppl);
6654
}
6755

6856
@Test
6957
public void asc_sort_timestamp_can_match_shortcut() throws IOException {
7058
String ppl = sanitize(loadFromFile("big5/queries/asc_sort_timestamp_can_match_shortcut.ppl"));
71-
timing("asc_sort_timestamp_can_match_shortcut", ppl);
59+
timing(summary, "asc_sort_timestamp_can_match_shortcut", ppl);
7260
}
7361

7462
@Test
7563
public void asc_sort_timestamp_no_can_match_shortcut() throws IOException {
7664
String ppl =
7765
sanitize(loadFromFile("big5/queries/asc_sort_timestamp_no_can_match_shortcut.ppl"));
78-
timing("asc_sort_timestamp_no_can_match_shortcut", ppl);
66+
timing(summary, "asc_sort_timestamp_no_can_match_shortcut", ppl);
7967
}
8068

8169
@Test
8270
public void asc_sort_with_after_timestamp() throws IOException {
8371
String ppl = sanitize(loadFromFile("big5/queries/asc_sort_with_after_timestamp.ppl"));
84-
timing("asc_sort_with_after_timestamp", ppl);
72+
timing(summary, "asc_sort_with_after_timestamp", ppl);
8573
}
8674

8775
@Test
8876
public void composite_date_histogram_daily() throws IOException {
8977
String ppl = sanitize(loadFromFile("big5/queries/composite_date_histogram_daily.ppl"));
90-
timing("composite_date_histogram_daily", ppl);
78+
timing(summary, "composite_date_histogram_daily", ppl);
9179
}
9280

9381
@Test
9482
public void composite_terms_keyword() throws IOException {
9583
String ppl = sanitize(loadFromFile("big5/queries/composite_terms_keyword.ppl"));
96-
timing("composite_terms_keyword", ppl);
84+
timing(summary, "composite_terms_keyword", ppl);
9785
}
9886

9987
@Test
10088
public void composite_terms() throws IOException {
10189
String ppl = sanitize(loadFromFile("big5/queries/composite_terms.ppl"));
102-
timing("composite_terms", ppl);
90+
timing(summary, "composite_terms", ppl);
10391
}
10492

10593
@Test
10694
public void date_histogram_hourly_agg() throws IOException {
10795
String ppl = sanitize(loadFromFile("big5/queries/date_histogram_hourly_agg.ppl"));
108-
timing("date_histogram_hourly_agg", ppl);
96+
timing(summary, "date_histogram_hourly_agg", ppl);
10997
}
11098

11199
@Test
112100
public void date_histogram_minute_agg() throws IOException {
113101
String ppl = sanitize(loadFromFile("big5/queries/date_histogram_minute_agg.ppl"));
114-
timing("date_histogram_minute_agg", ppl);
102+
timing(summary, "date_histogram_minute_agg", ppl);
115103
}
116104

117105
@Test
118106
public void test_default() throws IOException {
119107
String ppl = sanitize(loadFromFile("big5/queries/default.ppl"));
120-
timing("default", ppl);
108+
timing(summary, "default", ppl);
121109
}
122110

123111
@Test
124112
public void desc_sort_timestamp() throws IOException {
125113
String ppl = sanitize(loadFromFile("big5/queries/desc_sort_timestamp.ppl"));
126-
timing("desc_sort_timestamp", ppl);
114+
timing(summary, "desc_sort_timestamp", ppl);
127115
}
128116

129117
@Test
130118
public void desc_sort_timestamp_can_match_shortcut() throws IOException {
131119
String ppl = sanitize(loadFromFile("big5/queries/desc_sort_timestamp_can_match_shortcut.ppl"));
132-
timing("desc_sort_timestamp_can_match_shortcut", ppl);
120+
timing(summary, "desc_sort_timestamp_can_match_shortcut", ppl);
133121
}
134122

135123
@Test
136124
public void desc_sort_timestamp_no_can_match_shortcut() throws IOException {
137125
String ppl =
138126
sanitize(loadFromFile("big5/queries/desc_sort_timestamp_no_can_match_shortcut.ppl"));
139-
timing("desc_sort_timestamp_no_can_match_shortcut", ppl);
127+
timing(summary, "desc_sort_timestamp_no_can_match_shortcut", ppl);
140128
}
141129

142130
@Test
143131
public void desc_sort_with_after_timestamp() throws IOException {
144132
String ppl = sanitize(loadFromFile("big5/queries/desc_sort_with_after_timestamp.ppl"));
145-
timing("desc_sort_with_after_timestamp", ppl);
133+
timing(summary, "desc_sort_with_after_timestamp", ppl);
146134
}
147135

148136
@Test
149137
public void keyword_in_range() throws IOException {
150138
String ppl = sanitize(loadFromFile("big5/queries/keyword_in_range.ppl"));
151-
timing("keyword_in_range", ppl);
139+
timing(summary, "keyword_in_range", ppl);
152140
}
153141

154142
@Test
155143
public void keyword_terms() throws IOException {
156144
String ppl = sanitize(loadFromFile("big5/queries/keyword_terms.ppl"));
157-
timing("keyword_terms", ppl);
145+
timing(summary, "keyword_terms", ppl);
158146
}
159147

160148
@Test
161149
public void keyword_terms_low_cardinality() throws IOException {
162150
String ppl = sanitize(loadFromFile("big5/queries/keyword_terms_low_cardinality.ppl"));
163-
timing("keyword_terms_low_cardinality", ppl);
151+
timing(summary, "keyword_terms_low_cardinality", ppl);
164152
}
165153

166154
@Test
167155
public void multi_terms_keyword() throws IOException {
168156
String ppl = sanitize(loadFromFile("big5/queries/multi_terms_keyword.ppl"));
169-
timing("multi_terms_keyword", ppl);
157+
timing(summary, "multi_terms_keyword", ppl);
170158
}
171159

172160
@Test
173161
public void query_string_on_message() throws IOException {
174162
String ppl = sanitize(loadFromFile("big5/queries/query_string_on_message.ppl"));
175-
timing("query_string_on_message", ppl);
163+
timing(summary, "query_string_on_message", ppl);
176164
}
177165

178166
@Test
179167
public void query_string_on_message_filtered() throws IOException {
180168
String ppl = sanitize(loadFromFile("big5/queries/query_string_on_message_filtered.ppl"));
181-
timing("query_string_on_message_filtered", ppl);
169+
timing(summary, "query_string_on_message_filtered", ppl);
182170
}
183171

184172
@Test
185173
public void query_string_on_message_filtered_sorted_num() throws IOException {
186174
String ppl =
187175
sanitize(loadFromFile("big5/queries/query_string_on_message_filtered_sorted_num.ppl"));
188-
timing("query_string_on_message_filtered_sorted_num", ppl);
176+
timing(summary, "query_string_on_message_filtered_sorted_num", ppl);
189177
}
190178

191179
@Test
192180
public void range() throws IOException {
193181
String ppl = sanitize(loadFromFile("big5/queries/range.ppl"));
194-
timing("range", ppl);
182+
timing(summary, "range", ppl);
195183
}
196184

197-
@Ignore("Failed to parse request payload")
185+
@Test
198186
public void range_auto_date_histo() throws IOException {
199187
String ppl = sanitize(loadFromFile("big5/queries/range_auto_date_histo.ppl"));
200-
timing("range_auto_date_histo", ppl);
188+
timing(summary, "range_auto_date_histo", ppl);
201189
}
202190

203-
@Ignore("Failed to parse request payload")
191+
@Test
204192
public void range_auto_date_histo_with_metrics() throws IOException {
205193
String ppl = sanitize(loadFromFile("big5/queries/range_auto_date_histo_with_metrics.ppl"));
206-
timing("range_auto_date_histo_with_metrics", ppl);
194+
timing(summary, "range_auto_date_histo_with_metrics", ppl);
207195
}
208196

209197
@Test
210198
public void range_numeric() throws IOException {
211199
String ppl = sanitize(loadFromFile("big5/queries/range_numeric.ppl"));
212-
timing("range_numeric", ppl);
200+
timing(summary, "range_numeric", ppl);
213201
}
214202

215203
@Test
216204
public void range_field_conjunction_big_range_big_term_query() throws IOException {
217205
String ppl =
218206
sanitize(loadFromFile("big5/queries/range_field_conjunction_big_range_big_term_query.ppl"));
219-
timing("range_field_conjunction_big_range_big_term_query", ppl);
207+
timing(summary, "range_field_conjunction_big_range_big_term_query", ppl);
220208
}
221209

222210
@Test
223211
public void range_field_conjunction_small_range_big_term_query() throws IOException {
224212
String ppl =
225213
sanitize(
226214
loadFromFile("big5/queries/range_field_conjunction_small_range_big_term_query.ppl"));
227-
timing("range_field_conjunction_small_range_big_term_query", ppl);
215+
timing(summary, "range_field_conjunction_small_range_big_term_query", ppl);
228216
}
229217

230218
@Test
231219
public void range_field_conjunction_small_range_small_term_query() throws IOException {
232220
String ppl =
233221
sanitize(
234222
loadFromFile("big5/queries/range_field_conjunction_small_range_small_term_query.ppl"));
235-
timing("range_field_conjunction_small_range_small_term_query", ppl);
223+
timing(summary, "range_field_conjunction_small_range_small_term_query", ppl);
236224
}
237225

238226
@Test
239227
public void range_field_disjunction_big_range_small_term_query() throws IOException {
240228
String ppl =
241229
sanitize(
242230
loadFromFile("big5/queries/range_field_disjunction_big_range_small_term_query.ppl"));
243-
timing("range_field_disjunction_big_range_small_term_query", ppl);
231+
timing(summary, "range_field_disjunction_big_range_small_term_query", ppl);
244232
}
245233

246234
@Test
247235
public void range_with_asc_sort() throws IOException {
248236
String ppl = sanitize(loadFromFile("big5/queries/range_with_asc_sort.ppl"));
249-
timing("range_with_asc_sort", ppl);
237+
timing(summary, "range_with_asc_sort", ppl);
250238
}
251239

252240
@Test
253241
public void range_with_desc_sort() throws IOException {
254242
String ppl = sanitize(loadFromFile("big5/queries/range_with_desc_sort.ppl"));
255-
timing("range_with_desc_sort", ppl);
243+
timing(summary, "range_with_desc_sort", ppl);
256244
}
257245

258246
@Test
259247
public void scroll() throws IOException {
260248
String ppl = sanitize(loadFromFile("big5/queries/scroll.ppl"));
261-
timing("scroll", ppl);
249+
timing(summary, "scroll", ppl);
262250
}
263251

264252
@Test
265253
public void sort_keyword_can_match_shortcut() throws IOException {
266254
String ppl = sanitize(loadFromFile("big5/queries/sort_keyword_can_match_shortcut.ppl"));
267-
timing("sort_keyword_can_match_shortcut", ppl);
255+
timing(summary, "sort_keyword_can_match_shortcut", ppl);
268256
}
269257

270258
@Test
271259
public void sort_keyword_no_can_match_shortcut() throws IOException {
272260
String ppl = sanitize(loadFromFile("big5/queries/sort_keyword_no_can_match_shortcut.ppl"));
273-
timing("sort_keyword_no_can_match_shortcut", ppl);
261+
timing(summary, "sort_keyword_no_can_match_shortcut", ppl);
274262
}
275263

276264
@Test
277265
public void sort_numeric_asc() throws IOException {
278266
String ppl = sanitize(loadFromFile("big5/queries/sort_numeric_asc.ppl"));
279-
timing("sort_numeric_asc", ppl);
267+
timing(summary, "sort_numeric_asc", ppl);
280268
}
281269

282270
@Test
283271
public void sort_numeric_asc_with_match() throws IOException {
284272
String ppl = sanitize(loadFromFile("big5/queries/sort_numeric_asc_with_match.ppl"));
285-
timing("sort_numeric_asc_with_match", ppl);
273+
timing(summary, "sort_numeric_asc_with_match", ppl);
286274
}
287275

288276
@Test
289277
public void sort_numeric_desc() throws IOException {
290278
String ppl = sanitize(loadFromFile("big5/queries/sort_numeric_desc.ppl"));
291-
timing("sort_numeric_desc", ppl);
279+
timing(summary, "sort_numeric_desc", ppl);
292280
}
293281

294282
@Test
295283
public void sort_numeric_desc_with_match() throws IOException {
296284
String ppl = sanitize(loadFromFile("big5/queries/sort_numeric_desc_with_match.ppl"));
297-
timing("sort_numeric_desc_with_match", ppl);
285+
timing(summary, "sort_numeric_desc_with_match", ppl);
298286
}
299287

300288
@Test
301289
public void term() throws IOException {
302290
String ppl = sanitize(loadFromFile("big5/queries/term.ppl"));
303-
timing("term", ppl);
291+
timing(summary, "term", ppl);
304292
}
305293

306294
@Test
307295
public void terms_significant_1() throws IOException {
308296
String ppl = sanitize(loadFromFile("big5/queries/terms_significant_1.ppl"));
309-
timing("terms_significant_1", ppl);
297+
timing(summary, "terms_significant_1", ppl);
310298
}
311299

312300
@Test
313301
public void terms_significant_2() throws IOException {
314302
String ppl = sanitize(loadFromFile("big5/queries/terms_significant_2.ppl"));
315-
timing("terms_significant_2", ppl);
303+
timing(summary, "terms_significant_2", ppl);
316304
}
317305
}

0 commit comments

Comments
 (0)