File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/rules/logical Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change 1010import org .elasticsearch .compute .data .Block ;
1111import org .elasticsearch .compute .data .BlockUtils ;
1212import org .elasticsearch .index .IndexMode ;
13+ import org .elasticsearch .xpack .esql .core .expression .Alias ;
14+ import org .elasticsearch .xpack .esql .core .expression .Attribute ;
1315import org .elasticsearch .xpack .esql .core .expression .AttributeSet ;
1416import org .elasticsearch .xpack .esql .core .expression .EmptyAttribute ;
1517import org .elasticsearch .xpack .esql .core .expression .Expressions ;
@@ -84,7 +86,8 @@ public LogicalPlan apply(LogicalPlan plan) {
8486 );
8587 } else {
8688 // Aggs cannot produce pages with 0 columns, so retain one grouping.
87- remaining = List .of (Expressions .attribute (aggregate .groupings ().get (0 )));
89+ Attribute attribute = Expressions .attribute (aggregate .groupings ().getFirst ());
90+ remaining = aggregate .aggregates ().stream ().map (v -> new Alias (v .source (), v .name (), attribute )).toList ();
8891 p = aggregate .with (aggregate .groupings (), remaining );
8992 }
9093 } else {
You can’t perform that action at this time.
0 commit comments