Skip to content

Commit ff336e2

Browse files
committed
Non-long data type
1 parent 98c456c commit ff336e2

File tree

3 files changed

+79
-9
lines changed

3 files changed

+79
-9
lines changed

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/operator/ChangePointOperator.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
import org.apache.lucene.util.BytesRef;
1111
import org.elasticsearch.compute.data.Block;
1212
import org.elasticsearch.compute.data.BlockFactory;
13+
import org.elasticsearch.compute.data.BlockUtils;
1314
import org.elasticsearch.compute.data.BytesRefBlock;
1415
import org.elasticsearch.compute.data.DoubleBlock;
15-
import org.elasticsearch.compute.data.LongVector;
1616
import org.elasticsearch.compute.data.Page;
1717
import org.elasticsearch.xpack.ml.aggs.MlAggsHelper;
1818
import org.elasticsearch.xpack.ml.aggs.changepoint.ChangePointDetector;
@@ -93,16 +93,18 @@ private void createOutputPages() {
9393
double[] values = new double[valuesCount];
9494
int valuesIndex = 0;
9595
for (Page inputPage : inputPages) {
96-
// TODO: other data types
97-
LongVector vector = (LongVector) inputPage.getBlock(inputChannel).asVector();
98-
for (int i = 0; i < vector.getPositionCount(); i++) {
99-
values[valuesIndex++] = (double) vector.getLong(i);
96+
Block inputBlock = inputPage.getBlock(inputChannel);
97+
for (int i = 0; i < inputBlock.getPositionCount(); i++) {
98+
// TODO: nulls
99+
values[valuesIndex++] = ((Number) BlockUtils.toJavaObject(inputBlock, i)).doubleValue();
100100
}
101101
}
102102

103103
ChangeType changeType = ChangePointDetector.getChangeType(new MlAggsHelper.DoubleBucketValues(null, values));
104104
int changePointIndex = changeType.changePoint();
105105

106+
// TODO: throw error when indeterminable, due to not enough data
107+
106108
int pageStartIndex = 0;
107109
for (Page inputPage : inputPages) {
108110
Block changeTypeBlock;

x-pack/plugin/esql/qa/testFixtures/src/main/resources/change_point.csv-spec

Lines changed: 70 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
detect nothing
1+
detect nothing (long)
22
// TODO: required_capability: change_point
33

44
FROM k8s
@@ -33,7 +33,7 @@ count:long | @timestamp:datetime | type:text | pvalue:double
3333
;
3434

3535

36-
detect spike
36+
detect spike (long)
3737
// TODO: required_capability: change_point
3838

3939
FROM k8s
@@ -69,7 +69,7 @@ FROM k8s
6969
;
7070

7171

72-
detect step change
72+
detect step change (long)
7373
// TODO: required_capability: change_point
7474

7575
FROM k8s
@@ -103,3 +103,70 @@ FROM k8s
103103
2024-05-10T00:21:00.000Z | 104 | null | null
104104
2024-05-10T00:22:00.000Z | 109 | null | null
105105
;
106+
107+
108+
detect dip (double)
109+
// TODO: required_capability: change_point
110+
111+
FROM employees
112+
| STATS salary=AVG(salary) BY height
113+
| EVAL salary=CASE(height==2.1, 0.0, salary)
114+
| CHANGE_POINT salary ON height AS type, pvalue
115+
;
116+
117+
height:double | salary:double | type:text | pvalue:double
118+
1.41 | 40031.0 | null | null
119+
1.42 | 34142.5 | null | null
120+
1.44 | 40266.0 | null | null
121+
1.45 | 49095.0 | null | null
122+
1.46 | 39878.0 | null | null
123+
1.47 | 60408.0 | null | null
124+
1.48 | 44307.0 | null | null
125+
1.5 | 31120.0 | null | null
126+
1.51 | 28035.0 | null | null
127+
1.52 | 41243.5 | null | null
128+
1.53 | 60079.333333333336 | null | null
129+
1.54 | 61358.0 | null | null
130+
1.55 | 36876.5 | null | null
131+
1.56 | 60335.0 | null | null
132+
1.57 | 38486.0 | null | null
133+
1.58 | 41701.5 | null | null
134+
1.59 | 36575.666666666664 | null | null
135+
1.61 | 55299.5 | null | null
136+
1.63 | 70011.0 | null | null
137+
1.64 | 38992.0 | null | null
138+
1.66 | 28946.0 | null | null
139+
1.68 | 42155.5 | null | null
140+
1.69 | 45656.0 | null | null
141+
1.7 | 65092.25 | null | null
142+
1.74 | 53178.0 | null | null
143+
1.75 | 43429.0 | null | null
144+
1.77 | 54184.25 | null | null
145+
1.78 | 44147.5 | null | null
146+
1.79 | 55360.0 | null | null
147+
1.8 | 52833.0 | null | null
148+
1.81 | 56475.666666666664 | null | null
149+
1.82 | 56039.333333333336 | null | null
150+
1.83 | 54195.333333333336 | null | null
151+
1.85 | 66174.0 | null | null
152+
1.87 | 47411.0 | null | null
153+
1.89 | 58121.0 | null | null
154+
1.9 | 37112.0 | null | null
155+
1.91 | 39638.0 | null | null
156+
1.92 | 67492.0 | null | null
157+
1.93 | 33956.0 | null | null
158+
1.94 | 48193.333333333336 | null | null
159+
1.96 | 43026.0 | null | null
160+
1.97 | 52851.0 | null | null
161+
1.99 | 56068.0 | null | null
162+
2.0 | 36314.666666666664 | null | null
163+
2.01 | 35742.0 | null | null
164+
2.03 | 51130.5 | null | null
165+
2.04 | 49281.0 | null | null
166+
2.05 | 63528.0 | null | null
167+
2.06 | 56722.5 | null | null
168+
2.07 | 39984.0 | null | null
169+
2.08 | 60523.0 | null | null
170+
2.09 | 38645.0 | null | null
171+
2.1 | 0.0 | dip | 9.590143836835097E-6
172+
;

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/CsvTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,14 +327,15 @@ private void doTest() throws Exception {
327327
Releasables.close(() -> Iterators.map(actualResults.pages().iterator(), p -> p::releaseBlocks));
328328
// Give the breaker service some time to clear in case we got results before the rest of the driver had cleaned up
329329
// TODO: reenable + fix mem.leaks
330-
if (true) return;
330+
/*
331331
assertBusy(
332332
() -> assertThat(
333333
"Not all circuits were cleaned up",
334334
bigArrays.breakerService().getBreaker(CircuitBreaker.REQUEST).getUsed(),
335335
equalTo(0L)
336336
)
337337
);
338+
*/
338339
}
339340
}
340341

0 commit comments

Comments
 (0)