Skip to content

Commit dbe959a

Browse files
committed
TRANGE
1 parent 2249411 commit dbe959a

1 file changed

Lines changed: 7 additions & 21 deletions

File tree

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/PartitionTimeSeriesTests.java

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ private void runTest(
6262
long totalDocs,
6363
String minTimestampFromData,
6464
String maxTimestampFromData,
65-
String queryStartTs,
66-
String queryEndTs,
65+
String filter,
6766
ByteSizeValue rateBufferSize,
6867
int taskConcurrency,
6968
List<QueryRange> expectedRanges
@@ -104,21 +103,12 @@ public long count() {
104103
timeSeriesAnalyzer,
105104
new LogicalPlanOptimizer(new LogicalOptimizerContext(config, FoldContext.small(), TransportVersion.current()))
106105
);
107-
String filter1 = "";
108-
if (queryStartTs != null || randomBoolean()) {
109-
filter1 = "| WHERE @timestamp >= \"" + (queryStartTs != null ? queryStartTs : minTimestampFromData) + "\"";
110-
}
111-
String filter2 = "";
112-
if (queryEndTs != null || randomBoolean()) {
113-
filter2 = "| WHERE @timestamp <= \"" + (queryEndTs != null ? queryEndTs : maxTimestampFromData) + "\"";
114-
}
115106
String q = String.format(Locale.ROOT, """
116107
TS k8s
117108
%s
118-
%s
119109
| STATS max(rate(network.total_bytes_in)) BY cluster, BUCKET(@timestamp, 1 hour)
120110
| LIMIT 10
121-
""", filter1, filter2);
111+
""", (filter != null ? "| WHERE " + filter : ""));
122112
PhysicalPlan plan = planner.physicalPlan(q, timeSeriesAnalyzer);
123113
plan = PlannerUtils.integrateEsFilterIntoFragment(plan, null);
124114
plan = planner.optimizedPlan(plan, plannerSettings, searchStats, new EsqlFlags(true));
@@ -149,7 +139,6 @@ public void testPartition() {
149139
"2023-10-20T12:15:03.360Z",
150140
"2023-10-20T12:59:02.250Z",
151141
null,
152-
null,
153142
ByteSizeValue.ofMb(75),
154143
12, // 8 cpus
155144
List.of(
@@ -169,7 +158,6 @@ public void testPartition() {
169158
"2023-10-20T12:15:03.360Z",
170159
"2023-10-20T12:59:02.250Z",
171160
null,
172-
null,
173161
ByteSizeValue.ofMb(75),
174162
6, // 4 cpus
175163
List.of(
@@ -186,7 +174,6 @@ public void testPartition() {
186174
"2023-10-20T12:15:03.360Z",
187175
"2023-10-20T12:59:02.250Z",
188176
null,
189-
null,
190177
ByteSizeValue.ofMb(75),
191178
3, // 2 cpus
192179
List.of(
@@ -200,7 +187,6 @@ public void testPartition() {
200187
"2023-10-20T12:15:03.360Z",
201188
"2023-10-20T12:59:02.250Z",
202189
null,
203-
null,
204190
ByteSizeValue.ofMb(30), // smaller buffer to more smaller slices
205191
3, // 2 cpus
206192
List.of(
@@ -214,7 +200,6 @@ public void testPartition() {
214200
"2023-10-20T12:15:03.360Z",
215201
"2023-10-20T12:59:02.250Z",
216202
null,
217-
null,
218203
ByteSizeValue.ofMb(10), // smaller buffer to more smaller slices
219204
3, // 2 cpus
220205
List.of(
@@ -234,7 +219,6 @@ public void testPartition() {
234219
"2023-10-20T12:15:03.360Z",
235220
"2023-10-20T12:59:02.250Z",
236221
null,
237-
null,
238222
ByteSizeValue.ofMb(10), // smaller buffer to more smaller slices
239223
3, // 2 cpus
240224
List.of(
@@ -250,7 +234,6 @@ public void testPartitionWithQuery() {
250234
"2023-11-20T12:15:03.360Z",
251235
"2023-11-20T12:59:02.250Z",
252236
null,
253-
null,
254237
ByteSizeValue.ofMb(75),
255238
12, // 8 cpus
256239
List.of(
@@ -266,12 +249,15 @@ public void testPartitionWithQuery() {
266249
)
267250
);
268251

252+
String filter = randomFrom(
253+
"\"2023-11-20T12:16:03.360Z\" <= @timestamp AND @timestamp <= \"2023-11-20T12:57:02.250Z\"",
254+
"TRANGE(\"2023-11-20T12:16:03.359Z\", \"2023-11-20T12:57:02.250Z\")"
255+
);
269256
runTest(
270257
20_000_000L,
271258
"2023-11-20T12:15:03.360Z",
272259
"2023-11-20T12:59:02.250Z",
273-
"2023-11-20T12:16:03.360Z",
274-
"2023-11-20T12:57:02.250Z",
260+
filter,
275261
ByteSizeValue.ofMb(75),
276262
12, // 8 cpus
277263
List.of(

0 commit comments

Comments
 (0)