| 
17 | 17 | import org.elasticsearch.cluster.service.ClusterService;  | 
18 | 18 | import org.elasticsearch.common.io.stream.StreamInput;  | 
19 | 19 | import org.elasticsearch.common.io.stream.StreamOutput;  | 
20 |  | -import org.elasticsearch.common.lucene.BytesRefs;  | 
21 | 20 | import org.elasticsearch.common.util.CollectionUtils;  | 
22 | 21 | import org.elasticsearch.common.util.Maps;  | 
23 | 22 | import org.elasticsearch.common.util.concurrent.ConcurrentCollections;  | 
 | 
38 | 37 | import org.elasticsearch.xpack.core.ClientHelper;  | 
39 | 38 | import org.elasticsearch.xpack.core.enrich.EnrichMetadata;  | 
40 | 39 | import org.elasticsearch.xpack.core.enrich.EnrichPolicy;  | 
41 |  | -import org.elasticsearch.xpack.esql.EsqlIllegalArgumentException;  | 
42 | 40 | import org.elasticsearch.xpack.esql.action.EsqlExecutionInfo;  | 
43 | 41 | import org.elasticsearch.xpack.esql.analysis.EnrichResolution;  | 
44 |  | -import org.elasticsearch.xpack.esql.core.expression.Expression;  | 
45 |  | -import org.elasticsearch.xpack.esql.core.expression.Literal;  | 
46 | 42 | import org.elasticsearch.xpack.esql.core.type.DataType;  | 
47 | 43 | import org.elasticsearch.xpack.esql.core.type.EsField;  | 
48 | 44 | import org.elasticsearch.xpack.esql.core.util.StringUtils;  | 
 | 
63 | 59 | import java.util.Set;  | 
64 | 60 | import java.util.stream.Collectors;  | 
65 | 61 | 
 
  | 
66 |  | -import static org.elasticsearch.common.logging.LoggerMessageFormat.format;  | 
 | 62 | +import static org.elasticsearch.xpack.esql.core.expression.Foldables.stringLiteralValueOf;  | 
67 | 63 | import static org.elasticsearch.xpack.esql.session.EsqlCCSUtils.markClusterWithFinalStateAndNoShards;  | 
68 | 64 | 
 
  | 
69 | 65 | /**  | 
@@ -107,14 +103,7 @@ public EnrichPolicyResolver(  | 
107 | 103 | 
 
  | 
108 | 104 |     public record UnresolvedPolicy(String name, Enrich.Mode mode) {  | 
109 | 105 |         public static UnresolvedPolicy from(Enrich e) {  | 
110 |  | -            return new UnresolvedPolicy(asString(e.policyName()), e.mode());  | 
111 |  | -        }  | 
112 |  | - | 
113 |  | -        private static String asString(Expression expression) {  | 
114 |  | -            if (expression instanceof Literal literal) {  | 
115 |  | -                return BytesRefs.toString(literal.value());  | 
116 |  | -            }  | 
117 |  | -            throw new EsqlIllegalArgumentException(format(null, "Enrich policy must be a constant string"));  | 
 | 106 | +            return new UnresolvedPolicy(stringLiteralValueOf(e.policyName(), "Enrich policy must be a constant string"), e.mode());  | 
118 | 107 |         }  | 
119 | 108 |     }  | 
120 | 109 | 
 
  | 
 | 
0 commit comments