### Elasticsearch Version

8.11.0

### Installed Plugins

_No response_

### Java Version

_bundled_

### OS Version

MacOS

### Problem Description

When sending a ESQL query with the `enrich` command that involves a policy that does not existing a `NullPointerException` is thrown and shown as error messages to the user:

Query:
```
row a  = 1| enrich missing-policy
```

Returns:
```
null_pointer_exception - Cannot invoke "org.elasticsearch.xpack.core.enrich.EnrichPolicy.getMatchField()" because "policy" is null
```

### Steps to Reproduce

See above.

### Logs (if relevant)

_No response_
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Analyzer.java
plan = removeAggDuplicates(agg);
                }
            }
            return plan;
        }
        private static LogicalPlan removeAggDuplicates(Aggregate agg) {
            var groupings = agg.groupings();
            var newGroupings = new LinkedHashSet<>(groupings);
            
            groupings = newGroupings.size() == groupings.size() ? groupings : new ArrayList<>(newGroupings);
            var aggregates = agg.aggregates();
            var newAggregates = new ArrayList<>(aggregates);
            var nameSet = Sets.newHashSetWithExpectedSize(newAggregates.size());
            
            for (int i = newAggregates.size() - 1; i >= 0; i--) {
                var aggregate = newAggregates.get(i);
                if (nameSet.add(aggregate.name()) == false) {
                    newAggregates.remove(i);
                }
            }
            
            aggregates = newAggregates.size() == aggregates.size() ? aggregates : newAggregates;
            
            agg = (groupings == agg.groupings() && newAggregates == agg.aggregates())
                ? agg
                : new Aggregate(agg.source(), agg.child(), groupings, aggregates);
            return agg;
        }
    }
    private static class AddImplicitLimit extends ParameterizedRule<LogicalPlan, LogicalPlan, AnalyzerContext> {