Skip to content

Commit

Permalink
ESQL: Fix replacement of nested expressions in aggs with multiple par…
Browse files Browse the repository at this point in the history
…ameters (elastic#104718)
  • Loading branch information
luigidellaquila authored and henningandersen committed Jan 25, 2024
1 parent 3443f4e commit 821d0a3
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
6 changes: 6 additions & 0 deletions docs/changelog/104718.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 104718
summary: "ESQL: Fix replacement of nested expressions in aggs with multiple parameters"
area: ES|QL
type: bug
issues:
- 104706
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,21 @@ sum(sal):l | sum(salary + 10000):l | left(first_name, 1):s | concat(gender, t
43370 | 43370 | B | F2
;

nestedExpressionMultipleParams#[skip:-8.12.99,reason:supported in 8.13+]
FROM employees
| STATS p = percentile(emp_no + 10, 50), m = median(emp_no + 10) BY languages
| SORT languages
;

p:double | m:double | languages:integer
10053.0 | 10053.0 | 1
10069.0 | 10069.0 | 2
10068.0 | 10068.0 | 3
10060.5 | 10060.5 | 4
10076.0 | 10076.0 | 5
10034.5 | 10034.5 | null
;

groupByNull#[skip:-8.12.99,reason:bug fixed in 8.13+]
ROW a = 1, c = null
| STATS COUNT(a) BY c;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,16 @@ m:long | languages:i
20 | 5
10 | null
;


countDistinctWithGroupPrecisionAndNestedExpression#[skip:-8.12.99,reason:supported in 8.13+]
from employees | stats m = count_distinct(height + 5, 9876) by languages | sort languages;

m:long | languages:i
13 | 1
16 | 2
14 | 3
15 | 4
20 | 5
10 | null
;
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,9 @@ protected LogicalPlan rule(Aggregate aggregate) {
return newAlias.toAttribute();
});
// replace field with attribute
result = af.replaceChildren(Collections.singletonList(attr));
List<Expression> newChildren = new ArrayList<>(af.children());
newChildren.set(0, attr);
result = af.replaceChildren(newChildren);
}
return result;
});
Expand Down

0 comments on commit 821d0a3

Please sign in to comment.