Skip to content

Commit bab975a

Browse files
authored
License check for ES|QL categorize (elastic#126595) (elastic#126818)
1 parent f7b38d2 commit bab975a

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/grouping/Categorize.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
1111
import org.elasticsearch.common.io.stream.StreamInput;
1212
import org.elasticsearch.common.io.stream.StreamOutput;
13+
import org.elasticsearch.license.XPackLicenseState;
14+
import org.elasticsearch.xpack.esql.LicenseAware;
1315
import org.elasticsearch.xpack.esql.core.expression.Expression;
1416
import org.elasticsearch.xpack.esql.core.expression.Nullability;
1517
import org.elasticsearch.xpack.esql.core.tree.NodeInfo;
@@ -19,6 +21,7 @@
1921
import org.elasticsearch.xpack.esql.expression.function.FunctionInfo;
2022
import org.elasticsearch.xpack.esql.expression.function.Param;
2123
import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput;
24+
import org.elasticsearch.xpack.ml.MachineLearning;
2225

2326
import java.io.IOException;
2427
import java.util.List;
@@ -35,7 +38,7 @@
3538
* For the implementation, see {@link org.elasticsearch.compute.aggregation.blockhash.CategorizeBlockHash}
3639
* </p>
3740
*/
38-
public class Categorize extends GroupingFunction.NonEvaluatableGroupingFunction {
41+
public class Categorize extends GroupingFunction.NonEvaluatableGroupingFunction implements LicenseAware {
3942
public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(
4043
Expression.class,
4144
"Categorize",
@@ -126,4 +129,9 @@ public Expression field() {
126129
public String toString() {
127130
return "Categorize{field=" + field + "}";
128131
}
132+
133+
@Override
134+
public boolean licenseCheck(XPackLicenseState state) {
135+
return MachineLearning.CATEGORIZE_TEXT_AGG_FEATURE.check(state);
136+
}
129137
}

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ public class MachineLearning extends Plugin
526526
License.OperationMode.PLATINUM
527527
);
528528

529-
private static final LicensedFeature.Momentary CATEGORIZE_TEXT_AGG_FEATURE = LicensedFeature.momentary(
529+
public static final LicensedFeature.Momentary CATEGORIZE_TEXT_AGG_FEATURE = LicensedFeature.momentary(
530530
MachineLearningField.ML_FEATURE_FAMILY,
531531
"categorize-text-agg",
532532
License.OperationMode.PLATINUM

0 commit comments

Comments
 (0)