```
from employees | keep * | mv_expand first_name
```

throws UnresolvedException:

```
org.elasticsearch.xpack.ql.capabilities.UnresolvedException: Invalid call to attribute on an unresolved object ?*
        at org.elasticsearch.xpack.ql.expression.UnresolvedNamedExpression.toAttribute(UnresolvedNamedExpression.java:44)
        at org.elasticsearch.xpack.ql.expression.Expressions.asAttributes(Expressions.java:40)
        at org.elasticsearch.xpack.ql.plan.logical.Project.output(Project.java:62)
        at org.elasticsearch.xpack.esql.plan.logical.MvExpand.<init>(MvExpand.java:31)
        at org.elasticsearch.xpack.esql.parser.LogicalPlanBuilder.lambda$visitMvExpandCommand$3(LogicalPlanBuilder.java:154)
        at org.elasticsearch.xpack.esql.parser.LogicalPlanBuilder.visitCompositeQuery(LogicalPlanBuilder.java:89)
        at org.elasticsearch.xpack.esql.parser.LogicalPlanBuilder.visitCompositeQuery(LogicalPlanBuilder.java:66)
        at org.elasticsearch.xpack.esql.parser.EsqlBaseParser$CompositeQueryContext.accept(EsqlBaseParser.java:232)
        at org.elasticsearch.xpack.ql.parser.ParserUtils.typedParsing(ParserUtils.java:51)
        at org.elasticsearch.xpack.esql.parser.LogicalPlanBuilder.plan(LogicalPlanBuilder.java:73)
        at org.elasticsearch.xpack.esql.parser.LogicalPlanBuilder.visitSingleStatement(LogicalPlanBuilder.java:82)
        at org.elasticsearch.xpack.esql.parser.LogicalPlanBuilder.visitSingleStatement(LogicalPlanBuilder.java:66)
        at org.elasticsearch.xpack.esql.parser.EsqlBaseParser$SingleStatementContext.accept(EsqlBaseParser.java:169)
```

The problem is that MV_EXPAND tries to pre-calculate the output too early, when the resolution did not happen yet.
x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/StatementParserTests.java
Limit limit = (Limit) plan;
        assertThat(limit.limit(), instanceOf(Literal.class));
        assertThat(((Literal) limit.limit()).value(), equalTo(5));
        assertThat(limit.children().size(), equalTo(1));
        assertThat(limit.children().get(0), instanceOf(Filter.class));
        assertThat(limit.children().get(0).children().size(), equalTo(1));
        assertThat(limit.children().get(0).children().get(0), instanceOf(EsqlUnresolvedRelation.class));
    }
    public void testLimitConstraints() {
        expectError("from text | limit -1", "extraneous input '-' expecting INTEGER_LITERAL");
    }
    public void testBasicSortCommand() {
        LogicalPlan plan = statement("from text | where true | sort a+b asc nulls first, x desc nulls last | sort y asc | sort z desc");
        assertThat(plan, instanceOf(OrderBy.class));
        OrderBy orderBy = (OrderBy) plan;
        assertThat(orderBy.order().size(), equalTo(1));
        Order order = orderBy.order().get(0);
        assertThat(order.direction(), equalTo(Order.OrderDirection.DESC));
        assertThat(order.nullsPosition(), equalTo(Order.NullsPosition.FIRST));
        assertThat(order.child(), instanceOf(UnresolvedAttribute.class));
        assertThat(((UnresolvedAttribute) order.child()).name(), equalTo("z"));
        assertThat(orderBy.children().size(), equalTo(1));
        assertThat(orderBy.children().get(0), instanceOf(OrderBy.class));
        orderBy = (OrderBy) orderBy.children().get(0);
        assertThat(orderBy.order().size(), equalTo(1));
        order = orderBy.order().get(0);
        assertThat(order.direction(), equalTo(Order.OrderDirection.ASC));
        assertThat(order.nullsPosition(), equalTo(Order.NullsPosition.LAST));
        assertThat(order.child(), instanceOf(UnresolvedAttribute.class));
        assertThat(((UnresolvedAttribute) order.child()).name(), equalTo("y"));