The following query

```
row  a = \"a\", b = 1 | stats  e = min(b) by a | dissect a \"%{e}\" | mv_expand e
```


throws an IndexOutOfBoundsException when building the layout for MV_EXPAND.


x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/LocalExecutionPlanner.java
} else if (node instanceof MvExpandExec mvExpand) {
            return planMvExpand(mvExpand, context);
        }
        
        else if (node instanceof EsQueryExec esQuery) {
            return planEsQueryNode(esQuery, context);
        } else if (node instanceof EsStatsQueryExec statsQuery) {
            return planEsStats(statsQuery, context);
        } else if (node instanceof RowExec row) {
            return planRow(row, context);
        } else if (node instanceof LocalSourceExec localSource) {
            return planLocal(localSource, context);
        } else if (node instanceof ShowExec show) {
            return planShow(show);
        } else if (node instanceof ExchangeSourceExec exchangeSource) {
            return planExchangeSource(exchangeSource, context);
        }
        
        else if (node instanceof EnrichExec enrich) {
            return planEnrich(enrich, context);
        }
        
        else if (node instanceof OutputExec outputExec) {
            return planOutput(outputExec, context);
        } else if (node instanceof ExchangeSinkExec exchangeSink) {
            return planExchangeSink(exchangeSink, context);
        }
        throw new EsqlIllegalArgumentException("unknown physical plan node [" + node.nodeName() + "]");
    }
    private PhysicalOperation planAggregation(AggregateExec aggregate, LocalExecutionPlannerContext context) {