Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
costin committed Aug 29, 2024
1 parent 076425d commit 6c4eb06
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class InlineStats extends UnaryPlan implements NamedWriteable, Phased {
private List<Attribute> lazyOutput;

public InlineStats(Source source, Aggregate aggregate) {
super(source, aggregate.child());
super(source, aggregate);
this.aggregate = aggregate;
}

Expand All @@ -84,7 +84,7 @@ protected NodeInfo<InlineStats> info() {

@Override
public InlineStats replaceChild(LogicalPlan newChild) {
return new InlineStats(source(), aggregate.replaceChild(newChild));
return new InlineStats(source(), (Aggregate) newChild);
}

public Aggregate aggregate() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.elasticsearch.dissect.DissectParser;
import org.elasticsearch.index.IndexMode;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.junit.annotations.TestLogging;
import org.elasticsearch.xpack.esql.EsqlTestUtils;
import org.elasticsearch.xpack.esql.TestBlockFactory;
import org.elasticsearch.xpack.esql.VerificationException;
Expand Down Expand Up @@ -4546,9 +4547,10 @@ public void testReplaceSortByExpressionsWithStats() {
/**
* Expects
* Limit[1000[INTEGER]]
* \_InlineStats[[emp_no % 2{r}#6],[COUNT(salary{f}#12) AS c, emp_no % 2{r}#6]]
* \_Eval[[emp_no{f}#7 % 2[INTEGER] AS emp_no % 2]]
* \_EsRelation[test][_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, ge..]
* \_InlineStats[]
* \_Aggregate[STANDARD,[emp_no % 2{r}#3],[COUNT(salary{f}#13) AS c, emp_no % 2{r}#3]]
* \_Eval[[emp_no{f}#8 % 2[INTEGER] AS emp_no % 2]]
* \_EsRelation[test][_meta_field{f}#14, emp_no{f}#8, first_name{f}#9, ge..]
*/
public void testInlinestatsNestedExpressionsInGroups() {
var plan = optimizedPlan("""
Expand All @@ -4557,9 +4559,10 @@ public void testInlinestatsNestedExpressionsInGroups() {
""");

var limit = as(plan, Limit.class);
var agg = as(limit.child(), InlineStats.class);
var groupings = agg.aggregate().groupings();
var aggs = agg.aggregate().aggregates();
var inline = as(limit.child(), InlineStats.class);
var agg = as(inline.child(), Aggregate.class);
var groupings = agg.groupings();
var aggs = agg.aggregates();
var ref = as(groupings.get(0), ReferenceAttribute.class);
assertThat(aggs.get(1), is(ref));
var eval = as(agg.child(), Eval.class);
Expand Down

0 comments on commit 6c4eb06

Please sign in to comment.