Since merging https://github.com/elastic/elasticsearch/commit/4ca793ec1abeb986f8d1302884b8d64fd8dcdcbb

Two queries in the `elastic/logs` benchmarks are now failing with `Cannot invoke "java.lang.CharSequence.length()" because "text" is null`:

* esql_time_range_and_date_histogram_two_groups_pre_filter
* esql_time_range_and_date_histogram_two_groups_post_filter

The full stack-trace is reported at the end of this issue.

The first query:

```
FROM logs-* | EVAL start_time = DATE_PARSE(\"yyyy-MM-dd\",\"2020-01-01\"), end_time = DATE_PARSE(\"yyyy-MM-dd\",\"2020-01-02\") | WHERE @timestamp >= start_time AND @timestamp <= end_time AND http.response.body.bytes IS NOT NULL | EVAL bucket = DATE_TRUNC(1 hour, @timestamp) | STATS avg=AVG(http.response.body.bytes), min=MIN(http.response.body.bytes), max=MAX(http.response.body.bytes) BY data_stream.dataset, bucket | KEEP data_stream.dataset, bucket, min, avg, max
```

The second query:

```
FROM logs-* | EVAL start_time = DATE_PARSE(\"yyyy-MM-dd\",\"2020-01-01\"), end_time = DATE_PARSE(\"yyyy-MM-dd\",\"2020-01-02\") | WHERE @timestamp >= start_time AND @timestamp <= end_time | EVAL bucket = DATE_TRUNC(1 hour, @timestamp) | STATS avg=AVG(http.response.body.bytes), min=MIN(http.response.body.bytes), max=MAX(http.response.body.bytes) BY data_stream.dataset, bucket | WHERE min IS NOT NULL | KEEP data_stream.dataset, bucket, min, avg, max
```

The query passes if we restrict it to specific indices: `FROM logs-nginx.access-default ...`

To reproduce, use rally or esrally to run an ingest followed by the ESQL query:

```
rally race --pipeline=benchmark-only --target-host=127.0.0.1:9200  \
   --track-path=/Users/craig/dev/elastic/rally-tracks/elastic/logs \
   --revision=current \
   --on-error=abort --race-id="1234" --kill-running-processes \
   --challenge=logging-querying
```

Now run one of the failing queries using kibana, curl or some other UI, or run it in rally:


```
rally race --pipeline=benchmark-only --target-host=127.0.0.1:9200  \
   --track-path=/Users/craig/dev/elastic/rally-tracks/elastic/logs \
   --revision=current \
   --on-error=abort --race-id="1234" --kill-running-processes \
   --challenge=logging-querying --include-tasks "tag:esql"
```

You might need to set `--track-params` in the above commands. I can provide the ones I use for local testing if needed.

Stack trace:

```
org.elasticsearch.ElasticsearchException$1: Cannot invoke "java.lang.CharSequence.length()" because "text" is null
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.ElasticsearchException.guessRootCauses(ElasticsearchException.java:671)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.ElasticsearchException.generateFailureXContent(ElasticsearchException.java:599)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.rest.RestResponse.build(RestResponse.java:187)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.rest.RestResponse.<init>(RestResponse.java:135)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.rest.RestResponse.<init>(RestResponse.java:112)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.rest.action.RestActionListener.onFailure(RestActionListener.java:55)
	at org.elasticsearch.xpack.esql.action.EsqlResponseListener.lambda$wrapWithLogging$1(EsqlResponseListener.java:168)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.action.ActionListenerImplementations.safeAcceptException(ActionListenerImplementations.java:62)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.action.ActionListener$2.onFailure(ActionListener.java:185)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.rest.action.RestCancellableNodeClient$1.onFailure(RestCancellableNodeClient.java:96)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.client.internal.node.NodeClient$SafelyWrappedActionListener.onFailure(NodeClient.java:171)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.tasks.TaskManager$1.onFailure(TaskManager.java:215)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.action.ActionListenerImplementations.safeAcceptException(ActionListenerImplementations.java:62)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.action.ActionListenerImplementations.safeOnFailure(ActionListenerImplementations.java:73)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.action.DelegatingActionListener.onFailure(DelegatingActionListener.java:27)
	at org.elasticsearch.xpack.esql.plugin.ComputeService.lambda$execute$1(ComputeService.java:132)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.action.ActionListenerImplementations$DelegatingResponseActionListener.acceptException(ActionListenerImplementations.java:186)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.action.ActionListenerImplementations.safeAcceptException(ActionListenerImplementations.java:62)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.action.ActionListenerImplementations$DelegatingResponseActionListener.onFailure(ActionListenerImplementations.java:191)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.action.ActionListenerImplementations.safeAcceptException(ActionListenerImplementations.java:62)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.action.ActionListenerImplementations.safeOnFailure(ActionListenerImplementations.java:73)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.action.DelegatingActionListener.onFailure(DelegatingActionListener.java:27)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.action.support.RefCountingListener.finish(RefCountingListener.java:127)
	at org.elasticsearch.base@8.12.0-SNAPSHOT/org.elasticsearch.core.AbstractRefCounted$1.closeInternal(AbstractRefCounted.java:117)
	at org.elasticsearch.base@8.12.0-SNAPSHOT/org.elasticsearch.core.AbstractRefCounted.decRef(AbstractRefCounted.java:69)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.action.support.RefCountingRunnable.close(RefCountingRunnable.java:116)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.action.support.RefCountingListener$1.onFailure(RefCountingListener.java:158)
	at org.elasticsearch.xpack.esql.plugin.ComputeService.lambda$cancelOnFailure$11(ComputeService.java:234)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.action.ActionListenerImplementations$DelegatingResponseActionListener.acceptException(ActionListenerImplementations.java:186)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.action.ActionListenerImplementations.safeAcceptException(ActionListenerImplementations.java:62)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.action.ActionListenerImplementations$DelegatingResponseActionListener.onFailure(ActionListenerImplementations.java:191)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.action.ActionListenerImplementations.safeAcceptException(ActionListenerImplementations.java:62)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.action.ActionListenerImplementations.safeOnFailure(ActionListenerImplementations.java:73)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.action.DelegatingActionListener.onFailure(DelegatingActionListener.java:27)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.action.ActionListenerImplementations$RunAfterActionListener.onFailure(ActionListenerImplementations.java:269)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.action.ActionListenerImplementations.safeAcceptException(ActionListenerImplementations.java:62)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.action.ActionListenerImplementations.safeOnFailure(ActionListenerImplementations.java:73)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.action.DelegatingActionListener.onFailure(DelegatingActionListener.java:27)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.action.ActionListenerImplementations$RunAfterActionListener.onFailure(ActionListenerImplementations.java:269)
	at org.elasticsearch.compute.operator.DriverRunner$1.done(DriverRunner.java:96)
	at org.elasticsearch.compute.operator.DriverRunner$1.onFailure(DriverRunner.java:80)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.transport.TransportResponseHandler$1.handleException(TransportResponseHandler.java:64)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.transport.TransportService$UnregisterChildTransportResponseHandler.handleException(TransportService.java:1704)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.transport.TransportService$ContextRestoreResponseHandler.handleException(TransportService.java:1421)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.transport.TransportService$DirectResponseChannel.processException(TransportService.java:1557)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.transport.TransportService$DirectResponseChannel$2.doRun(TransportService.java:1537)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:33)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:983)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1623)
Caused by: java.lang.NullPointerException: Cannot invoke "java.lang.CharSequence.length()" because "text" is null
	at org.apache.lucene.core@9.8.0/org.apache.lucene.util.BytesRef.<init>(BytesRef.java:80)
	at org.elasticsearch.xpack.constantkeyword.mapper.ConstantKeywordFieldMapper$ConstantKeywordFieldType.blockLoader(ConstantKeywordFieldMapper.java:141)
	at org.elasticsearch.compute.lucene.BlockReaderFactories.factories(BlockReaderFactories.java:58)
	at org.elasticsearch.xpack.esql.planner.EsPhysicalOperationProviders.fieldExtractPhysicalOperation(EsPhysicalOperationProviders.java:78)
	at org.elasticsearch.xpack.esql.planner.LocalExecutionPlanner.planFieldExtractNode(LocalExecutionPlanner.java:272)
	at org.elasticsearch.xpack.esql.planner.LocalExecutionPlanner.plan(LocalExecutionPlanner.java:183)
	at org.elasticsearch.xpack.esql.planner.LocalExecutionPlanner.planAggregation(LocalExecutionPlanner.java:232)
	at org.elasticsearch.xpack.esql.planner.LocalExecutionPlanner.plan(LocalExecutionPlanner.java:181)
	at org.elasticsearch.xpack.esql.planner.LocalExecutionPlanner.planExchangeSink(LocalExecutionPlanner.java:376)
	at org.elasticsearch.xpack.esql.planner.LocalExecutionPlanner.plan(LocalExecutionPlanner.java:225)
	at org.elasticsearch.xpack.esql.planner.LocalExecutionPlanner.plan(LocalExecutionPlanner.java:167)
	at org.elasticsearch.xpack.esql.plugin.ComputeService.runCompute(ComputeService.java:260)
	at org.elasticsearch.xpack.esql.plugin.ComputeService$DataNodeRequestHandler.lambda$messageReceived$5(ComputeService.java:432)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.action.ActionListener$2.onResponse(ActionListener.java:177)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.action.ActionListener.completeWith(ActionListener.java:305)
	at org.elasticsearch.xpack.esql.plugin.ComputeService.lambda$acquireSearchContexts$15(ComputeService.java:301)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.index.shard.IndexShard.ensureShardSearchActive(IndexShard.java:3933)
	at org.elasticsearch.xpack.esql.plugin.ComputeService.acquireSearchContexts(ComputeService.java:299)
	at org.elasticsearch.xpack.esql.plugin.ComputeService$DataNodeRequestHandler.messageReceived(ComputeService.java:430)
	at org.elasticsearch.xpack.esql.plugin.ComputeService$DataNodeRequestHandler.messageReceived(ComputeService.java:422)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:75)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.transport.TransportService$6.doRun(TransportService.java:1020)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:983)
	... 7 more
"""
      }
    ],
    "type": "null_pointer_exception",
    "reason": """Cannot invoke "java.lang.CharSequence.length()" because "text" is null""",
    "stack_trace": """java.lang.NullPointerException: Cannot invoke "java.lang.CharSequence.length()" because "text" is null
	at org.apache.lucene.core@9.8.0/org.apache.lucene.util.BytesRef.<init>(BytesRef.java:80)
	at org.elasticsearch.xpack.constantkeyword.mapper.ConstantKeywordFieldMapper$ConstantKeywordFieldType.blockLoader(ConstantKeywordFieldMapper.java:141)
	at org.elasticsearch.compute.lucene.BlockReaderFactories.factories(BlockReaderFactories.java:58)
	at org.elasticsearch.xpack.esql.planner.EsPhysicalOperationProviders.fieldExtractPhysicalOperation(EsPhysicalOperationProviders.java:78)
	at org.elasticsearch.xpack.esql.planner.LocalExecutionPlanner.planFieldExtractNode(LocalExecutionPlanner.java:272)
	at org.elasticsearch.xpack.esql.planner.LocalExecutionPlanner.plan(LocalExecutionPlanner.java:183)
	at org.elasticsearch.xpack.esql.planner.LocalExecutionPlanner.planAggregation(LocalExecutionPlanner.java:232)
	at org.elasticsearch.xpack.esql.planner.LocalExecutionPlanner.plan(LocalExecutionPlanner.java:181)
	at org.elasticsearch.xpack.esql.planner.LocalExecutionPlanner.planExchangeSink(LocalExecutionPlanner.java:376)
	at org.elasticsearch.xpack.esql.planner.LocalExecutionPlanner.plan(LocalExecutionPlanner.java:225)
	at org.elasticsearch.xpack.esql.planner.LocalExecutionPlanner.plan(LocalExecutionPlanner.java:167)
	at org.elasticsearch.xpack.esql.plugin.ComputeService.runCompute(ComputeService.java:260)
	at org.elasticsearch.xpack.esql.plugin.ComputeService$DataNodeRequestHandler.lambda$messageReceived$5(ComputeService.java:432)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.action.ActionListener$2.onResponse(ActionListener.java:177)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.action.ActionListener.completeWith(ActionListener.java:305)
	at org.elasticsearch.xpack.esql.plugin.ComputeService.lambda$acquireSearchContexts$15(ComputeService.java:301)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.index.shard.IndexShard.ensureShardSearchActive(IndexShard.java:3933)
	at org.elasticsearch.xpack.esql.plugin.ComputeService.acquireSearchContexts(ComputeService.java:299)
	at org.elasticsearch.xpack.esql.plugin.ComputeService$DataNodeRequestHandler.messageReceived(ComputeService.java:430)
	at org.elasticsearch.xpack.esql.plugin.ComputeService$DataNodeRequestHandler.messageReceived(ComputeService.java:422)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:75)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.transport.TransportService$6.doRun(TransportService.java:1020)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:983)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:33)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:983)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1623)
```
x-pack/plugin/mapper-constant-keyword/src/test/java/org/elasticsearch/xpack/constantkeyword/mapper/ConstantKeywordFieldMapperTests.java
throw new AssumptionViolatedException("copy_to on constant_keyword not supported");
            }
        };
    }
    @Override
    protected IngestScriptSupport ingestScriptSupport() {
        throw new AssumptionViolatedException("not supported");
    }
    @Override
    protected Function<Object, Object> loadBlockExpected() {
        return v -> ((BytesRef) v).utf8ToString();
    }
    public void testNullValueSyntheticSource() throws IOException {
        DocumentMapper mapper = createDocumentMapper(syntheticSourceMapping(b -> {
            b.startObject("field");
            b.field("type", "constant_keyword");
            b.endObject();
        }));
        assertThat(syntheticSource(mapper, b -> {}), equalTo("{}"));
    }
    @Override
    protected boolean supportsEmptyInputArray() {
        return false;
    }
    @Override
    protected boolean addsValueWhenNotSupplied() {
        return true;
    }
}