Skip to content

Commit

Permalink
Rename capability to CATEGORIZE_V2
Browse files Browse the repository at this point in the history
  • Loading branch information
ivancea committed Nov 27, 2024
1 parent b622e6c commit 30412ad
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 39 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
standard aggs
required_capability: categorize
required_capability: categorize_v2

FROM sample_data
| STATS count=COUNT(),
Expand All @@ -17,7 +17,7 @@ count:long | sum:long | avg:double | count_distinct:long | category:keyw
;

values aggs
required_capability: categorize
required_capability: categorize_v2

FROM sample_data
| STATS values=MV_SORT(VALUES(message)),
Expand All @@ -33,7 +33,7 @@ values:keyword | top
;

mv
required_capability: categorize
required_capability: categorize_v2

FROM mv_sample_data
| STATS COUNT() BY category=CATEGORIZE(message)
Expand All @@ -48,7 +48,7 @@ COUNT():long | category:keyword
;

row mv
required_capability: categorize
required_capability: categorize_v2

ROW message = ["connected to a", "connected to b", "disconnected"]
| STATS COUNT() BY category=CATEGORIZE(message)
Expand All @@ -61,7 +61,7 @@ COUNT():long | category:keyword
;

with multiple indices
required_capability: categorize
required_capability: categorize_v2
required_capability: union_types

FROM sample_data*
Expand All @@ -76,7 +76,7 @@ COUNT():long | category:keyword
;

mv with many values
required_capability: categorize
required_capability: categorize_v2

FROM employees
| STATS COUNT() BY category=CATEGORIZE(job_positions)
Expand All @@ -93,7 +93,7 @@ COUNT():long | category:keyword
;

mv via eval
required_capability: categorize
required_capability: categorize_v2

FROM sample_data
| EVAL message = MV_APPEND(message, "Banana")
Expand All @@ -109,7 +109,7 @@ COUNT():long | category:keyword
;

mv via eval const
required_capability: categorize
required_capability: categorize_v2

FROM sample_data
| EVAL message = ["Banana", "Bread"]
Expand All @@ -123,7 +123,7 @@ COUNT():long | category:keyword
;

mv via eval const without aliases
required_capability: categorize
required_capability: categorize_v2

FROM sample_data
| EVAL message = ["Banana", "Bread"]
Expand All @@ -137,7 +137,7 @@ COUNT():long | CATEGORIZE(message):keyword
;

mv const in parameter
required_capability: categorize
required_capability: categorize_v2

FROM sample_data
| STATS COUNT() BY c = CATEGORIZE(["Banana", "Bread"])
Expand All @@ -150,7 +150,7 @@ COUNT():long | c:keyword
;

agg alias shadowing
required_capability: categorize
required_capability: categorize_v2

FROM sample_data
| STATS c = COUNT() BY c = CATEGORIZE(["Banana", "Bread"])
Expand All @@ -165,7 +165,7 @@ c:keyword
;

chained aggregations using categorize
required_capability: categorize
required_capability: categorize_v2

FROM sample_data
| STATS COUNT() BY category=CATEGORIZE(message)
Expand All @@ -180,7 +180,7 @@ COUNT():long | category:keyword
;

stats without aggs
required_capability: categorize
required_capability: categorize_v2

FROM sample_data
| STATS BY category=CATEGORIZE(message)
Expand All @@ -194,7 +194,7 @@ category:keyword
;

text field
required_capability: categorize
required_capability: categorize_v2

FROM hosts
| STATS COUNT() BY category=CATEGORIZE(host_group)
Expand All @@ -208,7 +208,7 @@ COUNT():long | category:keyword
;

on TO_UPPER
required_capability: categorize
required_capability: categorize_v2

FROM sample_data
| STATS COUNT() BY category=CATEGORIZE(TO_UPPER(message))
Expand All @@ -222,7 +222,7 @@ COUNT():long | category:keyword
;

on CONCAT
required_capability: categorize
required_capability: categorize_v2

FROM sample_data
| STATS COUNT() BY category=CATEGORIZE(CONCAT(message, " banana"))
Expand All @@ -236,7 +236,7 @@ COUNT():long | category:keyword
;

on CONCAT with unicode
required_capability: categorize
required_capability: categorize_v2

FROM sample_data
| STATS COUNT() BY category=CATEGORIZE(CONCAT(message, " 👍🏽😊"))
Expand All @@ -250,7 +250,7 @@ COUNT():long | category:keyword
;

on REVERSE(CONCAT())
required_capability: categorize
required_capability: categorize_v2

FROM sample_data
| STATS COUNT() BY category=CATEGORIZE(REVERSE(CONCAT(message, " 👍🏽😊")))
Expand All @@ -264,7 +264,7 @@ COUNT():long | category:keyword
;

and then TO_LOWER
required_capability: categorize
required_capability: categorize_v2

FROM sample_data
| STATS COUNT() BY category=CATEGORIZE(message)
Expand All @@ -280,7 +280,7 @@ COUNT():long | category:keyword

# Throws NPE - Requires nulls support
on const empty string-Ignore
required_capability: categorize
required_capability: categorize_v2

FROM sample_data
| STATS COUNT() BY category=CATEGORIZE("")
Expand All @@ -293,7 +293,7 @@ COUNT():long | category:keyword

# Throws NPE - Requires nulls support
on const empty string from eval-Ignore
required_capability: categorize
required_capability: categorize_v2

FROM sample_data
| EVAL x = ""
Expand All @@ -306,7 +306,7 @@ COUNT():long | category:keyword
;

on null
required_capability: categorize
required_capability: categorize_v2

FROM sample_data
| EVAL x = null
Expand All @@ -318,7 +318,7 @@ COUNT():long | category:keyword
;

on null string
required_capability: categorize
required_capability: categorize_v2

FROM sample_data
| EVAL x = null::string
Expand All @@ -330,7 +330,7 @@ COUNT():long | category:keyword
;

filtering out all data
required_capability: categorize
required_capability: categorize_v2

FROM sample_data
| WHERE @timestamp < "2023-10-23T00:00:00Z"
Expand All @@ -342,7 +342,7 @@ COUNT():long | category:keyword
;

filtering out all data with constant
required_capability: categorize
required_capability: categorize_v2

FROM sample_data
| STATS COUNT() BY category=CATEGORIZE(message)
Expand All @@ -353,7 +353,7 @@ COUNT():long | category:keyword
;

drop output columns
required_capability: categorize
required_capability: categorize_v2

FROM sample_data
| STATS count=COUNT() BY category=CATEGORIZE(message)
Expand All @@ -368,7 +368,7 @@ x:integer
;

category value processing
required_capability: categorize
required_capability: categorize_v2

ROW message = ["connected to a", "connected to b", "disconnected"]
| STATS COUNT() BY category=CATEGORIZE(message)
Expand All @@ -382,7 +382,7 @@ COUNT():long | category:keyword
;

row aliases
required_capability: categorize
required_capability: categorize_v2

ROW message = "connected to a"
| EVAL x = message
Expand All @@ -396,7 +396,7 @@ COUNT():long | category:keyword | y:keyword
;

from aliases
required_capability: categorize
required_capability: categorize_v2

FROM sample_data
| EVAL x = message
Expand All @@ -412,7 +412,7 @@ COUNT():long | category:keyword | y:keyword
;

row aliases with keep
required_capability: categorize
required_capability: categorize_v2

ROW message = "connected to a"
| EVAL x = message
Expand All @@ -428,7 +428,7 @@ COUNT():long | y:keyword
;

from aliases with keep
required_capability: categorize
required_capability: categorize_v2

FROM sample_data
| EVAL x = message
Expand All @@ -446,7 +446,7 @@ COUNT():long | y:keyword
;

row rename
required_capability: categorize
required_capability: categorize_v2

ROW message = "connected to a"
| RENAME message as x
Expand All @@ -460,7 +460,7 @@ COUNT():long | y:keyword
;

from rename
required_capability: categorize
required_capability: categorize_v2

FROM sample_data
| RENAME message as x
Expand All @@ -476,7 +476,7 @@ COUNT():long | y:keyword
;

row drop
required_capability: categorize
required_capability: categorize_v2

ROW message = "connected to a"
| STATS c = COUNT() BY category=CATEGORIZE(message)
Expand All @@ -489,7 +489,7 @@ c:long
;

from drop
required_capability: categorize
required_capability: categorize_v2

FROM sample_data
| STATS c = COUNT() BY category=CATEGORIZE(message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,11 @@ public enum Cap {

/**
* Supported the text categorization function "CATEGORIZE".
* <p>
* This capability was initially named `CATEGORIZE`, and got renamed after the function started correctly returning keywords.
* </p>
*/
CATEGORIZE(Build.current().isSnapshot()),
CATEGORIZE_V2(Build.current().isSnapshot()),

/**
* QSTR function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1821,7 +1821,7 @@ public void testIntervalAsString() {
}

public void testCategorizeSingleGrouping() {
assumeTrue("requires Categorize capability", EsqlCapabilities.Cap.CATEGORIZE.isEnabled());
assumeTrue("requires Categorize capability", EsqlCapabilities.Cap.CATEGORIZE_V2.isEnabled());

query("from test | STATS COUNT(*) BY CATEGORIZE(first_name)");
query("from test | STATS COUNT(*) BY cat = CATEGORIZE(first_name)");
Expand Down Expand Up @@ -1850,7 +1850,7 @@ public void testCategorizeSingleGrouping() {
}

public void testCategorizeNestedGrouping() {
assumeTrue("requires Categorize capability", EsqlCapabilities.Cap.CATEGORIZE.isEnabled());
assumeTrue("requires Categorize capability", EsqlCapabilities.Cap.CATEGORIZE_V2.isEnabled());

query("from test | STATS COUNT(*) BY CATEGORIZE(LENGTH(first_name)::string)");

Expand All @@ -1865,7 +1865,7 @@ public void testCategorizeNestedGrouping() {
}

public void testCategorizeWithinAggregations() {
assumeTrue("requires Categorize capability", EsqlCapabilities.Cap.CATEGORIZE.isEnabled());
assumeTrue("requires Categorize capability", EsqlCapabilities.Cap.CATEGORIZE_V2.isEnabled());

query("from test | STATS MV_COUNT(cat), COUNT(*) BY cat = CATEGORIZE(first_name)");

Expand Down

0 comments on commit 30412ad

Please sign in to comment.