Skip to content

Commit

Permalink
ESQL: Make Categorize usable in aggs when identical to a grouping (#1…
Browse files Browse the repository at this point in the history
…17835)

Cases like `STATS MV_APPEND(cat, CATEGORIZE(x)) BY cat=CATEGORIZE(x)` should work, as they're moved to an EVAL by a rule.

Also, these cases were discarded, as they fail because of other verifications (Which also fail for BUCKET):
```
STATS x = category BY category=CATEGORIZE(message)
STATS x = CATEGORIZE(message) BY CATEGORIZE(message)
STATS x = CATEGORIZE(message) BY category=CATEGORIZE(message)
  • Loading branch information
ivancea authored Dec 3, 2024
1 parent cca7051 commit 03a71d2
Show file tree
Hide file tree
Showing 9 changed files with 167 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,27 @@ FROM employees
//end::reuseGroupingFunctionWithExpression-result[]
;

reuseGroupingFunctionImplicitAliasWithExpression#[skip:-8.13.99, reason:BUCKET renamed in 8.14]
FROM employees
| STATS s1 = `BUCKET(salary / 100 + 99, 50.)` + 1, s2 = BUCKET(salary / 1000 + 999, 50.) + 2 BY BUCKET(salary / 100 + 99, 50.), b2 = BUCKET(salary / 1000 + 999, 50.)
| SORT `BUCKET(salary / 100 + 99, 50.)`, b2
| KEEP s1, `BUCKET(salary / 100 + 99, 50.)`, s2, b2
;

s1:double | BUCKET(salary / 100 + 99, 50.):double | s2:double | b2:double
351.0 |350.0 |1002.0 |1000.0
401.0 |400.0 |1002.0 |1000.0
451.0 |450.0 |1002.0 |1000.0
501.0 |500.0 |1002.0 |1000.0
551.0 |550.0 |1002.0 |1000.0
601.0 |600.0 |1002.0 |1000.0
601.0 |600.0 |1052.0 |1050.0
651.0 |650.0 |1052.0 |1050.0
701.0 |700.0 |1052.0 |1050.0
751.0 |750.0 |1052.0 |1050.0
801.0 |800.0 |1052.0 |1050.0
;

reuseGroupingFunctionWithinAggs#[skip:-8.13.99, reason:BUCKET renamed in 8.14]
FROM employees
| STATS sum = 1 + MAX(1 + BUCKET(salary, 1000.)) BY BUCKET(salary, 1000.) + 1
Expand Down
Loading

0 comments on commit 03a71d2

Please sign in to comment.