|
16 | 16 | import org.elasticsearch.license.XPackLicenseState; |
17 | 17 | import org.elasticsearch.xpack.esql.LicenseAware; |
18 | 18 | import org.elasticsearch.xpack.esql.SupportsObservabilityTier; |
| 19 | +import org.elasticsearch.xpack.esql.common.Failures; |
19 | 20 | import org.elasticsearch.xpack.esql.core.InvalidArgumentException; |
| 21 | +import org.elasticsearch.xpack.esql.core.expression.Alias; |
20 | 22 | import org.elasticsearch.xpack.esql.core.expression.Expression; |
21 | 23 | import org.elasticsearch.xpack.esql.core.expression.MapExpression; |
22 | 24 | import org.elasticsearch.xpack.esql.core.expression.Nullability; |
|
33 | 35 | import org.elasticsearch.xpack.esql.expression.function.Options; |
34 | 36 | import org.elasticsearch.xpack.esql.expression.function.Param; |
35 | 37 | import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput; |
| 38 | +import org.elasticsearch.xpack.esql.plan.logical.Aggregate; |
| 39 | +import org.elasticsearch.xpack.esql.plan.logical.InlineStats; |
| 40 | +import org.elasticsearch.xpack.esql.plan.logical.LogicalPlan; |
36 | 41 | import org.elasticsearch.xpack.ml.MachineLearning; |
37 | 42 |
|
38 | 43 | import java.io.IOException; |
|
41 | 46 | import java.util.Locale; |
42 | 47 | import java.util.Map; |
43 | 48 | import java.util.TreeMap; |
| 49 | +import java.util.function.BiConsumer; |
44 | 50 |
|
45 | 51 | import static java.util.Map.entry; |
46 | 52 | import static org.elasticsearch.common.logging.LoggerMessageFormat.format; |
47 | 53 | import static org.elasticsearch.compute.aggregation.blockhash.BlockHash.CategorizeDef.OutputFormat.REGEX; |
48 | 54 | import static org.elasticsearch.xpack.esql.SupportsObservabilityTier.ObservabilityTier.COMPLETE; |
| 55 | +import static org.elasticsearch.xpack.esql.common.Failure.fail; |
49 | 56 | import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.DEFAULT; |
50 | 57 | import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.SECOND; |
51 | 58 | import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isString; |
@@ -248,4 +255,26 @@ public String toString() { |
248 | 255 | public boolean licenseCheck(XPackLicenseState state) { |
249 | 256 | return MachineLearning.CATEGORIZE_TEXT_AGG_FEATURE.check(state); |
250 | 257 | } |
| 258 | + |
| 259 | + @Override |
| 260 | + public BiConsumer<LogicalPlan, Failures> postAnalysisPlanVerification() { |
| 261 | + return (p, failures) -> { |
| 262 | + super.postAnalysisPlanVerification().accept(p, failures); |
| 263 | + |
| 264 | + if (p instanceof InlineStats inlineStats && inlineStats.child() instanceof Aggregate aggregate) { |
| 265 | + aggregate.groupings().forEach(grp -> { |
| 266 | + if (grp instanceof Alias alias && alias.child() instanceof Categorize categorize) { |
| 267 | + failures.add( |
| 268 | + fail( |
| 269 | + categorize, |
| 270 | + "CATEGORIZE [{}] is not yet supported with INLINESTATS [{}]", |
| 271 | + categorize.sourceText(), |
| 272 | + inlineStats.sourceText() |
| 273 | + ) |
| 274 | + ); |
| 275 | + } |
| 276 | + }); |
| 277 | + } |
| 278 | + }; |
| 279 | + } |
251 | 280 | } |
0 commit comments