-
Notifications
You must be signed in to change notification settings - Fork 26k
[ESQL] Add a BY clause to CHANGE_POINT command #145210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 24 commits
0307f52
081a557
769fc78
7379341
16db485
b2f0161
a70e5b9
e14cccb
294dec4
057d781
254a3f6
59a30a3
bed2254
f75395c
8233ba2
decb5a9
6dbd9cd
8113031
a1d9975
d4cdc6b
1ac27e9
d66805c
862fbae
5d2337a
7a45883
583c302
f1a0a57
f8f57b6
2a15f9a
8cf6877
cd077bd
cbd8397
f716705
ec2edf5
8e88131
a9ec094
b1aba0d
b1ba66b
d9ecd28
5f23df6
0d2836e
f1ff89f
7e9329a
72587cb
3457543
b4a0a74
6dfaf3f
71b94a1
5305ea1
f9f9ea6
55880ad
c3f0542
dad3efd
aeb8ac8
185bca9
6f2be47
7f8b36c
afb5f3a
aecd0b3
61614ce
a61ebe0
38d8e15
d043395
3250694
a7876b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| % This is generated by ESQL's CommandDocsTests. Do not edit it. See ../README.md for how to regenerate it. | ||
|
|
||
| ```esql | ||
| ROW k=[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], g=[0,1,2] | ||
| | MV_EXPAND k | ||
| | MV_EXPAND g | ||
| | EVAL value=CASE(k<13, 0, 42) | ||
| | CHANGE_POINT value ON k BY g | ||
| | WHERE type IS NOT NULL | ||
| ``` | ||
|
|
||
| | k:integer | g:integer | value:integer | type:keyword | pvalue:double | | ||
| | --- | --- | --- | --- | --- | | ||
| | 13 | 0 | 42 | step_change | 0.0 | | ||
| | 13 | 1 | 42 | step_change | 0.0 | | ||
| | 13 | 2 | 42 | step_change | 0.0 | | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,7 @@ The `CHANGE_POINT` command requires a [platinum license](https://www.elastic.co/ | |
| ## Syntax | ||
|
|
||
| ```esql | ||
| CHANGE_POINT value [ON key] [AS type_name, pvalue_name] | ||
| CHANGE_POINT value [ON key] [BY group] [AS type_name, pvalue_name] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @darius-vil we must keep version changes relevant for all users on 9.x this change is only relevant to 9.4+ so we need to tag it appropriately with applies_to tags See this comment for pointers on that : #144300 (comment)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you could keep the old one in a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for pointing this out! I meant to ask how do these work, but it completely slipped my mind in the end... I'll fix this in a sec
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the time being, I marked all the new switches/sections/inline changes with Since CHANGE_POINT BY hinges on recently introduced LIMIT BY, I guess our release lifecycle should follow theirs? I'll keep this comment open until I find the answer
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cool you'll definitely need |
||
| ``` | ||
|
|
||
| ## Parameters | ||
|
|
@@ -23,6 +23,9 @@ CHANGE_POINT value [ON key] [AS type_name, pvalue_name] | |
| `key` | ||
| : The column with the key to order the values by. If not specified, `@timestamp` is used. | ||
|
|
||
| `group` | ||
|
darius-vil marked this conversation as resolved.
Outdated
|
||
| : The column to group values by. When specified, change point detection is performed independently for each group. | ||
|
|
||
| `type_name` | ||
| : The name of the output column with the change point type. If not specified, `type` is used. | ||
|
|
||
|
|
@@ -44,6 +47,7 @@ The possible change point types are: | |
|
|
||
| ::::{note} | ||
| There must be at least 22 values for change point detection. Any values beyond the first 1,000 are ignored. | ||
| When a `BY` clause is provided, these rules apply per group. | ||
|
darius-vil marked this conversation as resolved.
Outdated
|
||
| :::: | ||
|
|
||
| ## Examples | ||
|
|
@@ -52,3 +56,8 @@ The following example detects a step change in a metric: | |
|
|
||
| :::{include} ../examples/change_point.csv-spec/changePointForDocs.md | ||
| ::: | ||
|
|
||
| The following example detects a step change independently for each group: | ||
|
darius-vil marked this conversation as resolved.
Outdated
|
||
|
|
||
| :::{include} ../examples/change_point.csv-spec/changePointForDocsByGroup.md | ||
| ::: | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this example not very interesting.
What about:
location = [13,14,15](instead ofg)BY locationAt least you get some different result rows.
You can probably do even better than this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I applied your suggestion - gives a better demonstration without adding much complexity.
As for making it even better, a lot of other examples in our docs start from a ready dataset (
FROM employees).This would be great for change_point doc too - we would get rid of the ROW, MV_EXPAND, EVAL at the start and focus on the command itself.
The employees data isn't the best to demonstrate CHANGE_POINT though, we might need a different datasource. Can we do this in a follow up?