-
Notifications
You must be signed in to change notification settings - Fork 25k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESQL: Fix layout when aggregating with aliases #117832
ESQL: Fix layout when aggregating with aliases #117832
Conversation
Pinging @elastic/es-analytical-engine (Team:Analytics) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be merged to main and then backported? To avoid conflicts, and ensure we support "everything everywhere".
I see you commented to fix it here, and then remove the obsolete path in main. But I wonder if it could cause issues in the future. Also, if it fails in <8.13, shouldn't 9.x also support it? Or is 8.13 the last compatible 8.x version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, I see the other PR is identical
for (NamedExpression agg : aggregates) { | ||
if (agg instanceof Alias a) { | ||
if (a.child() instanceof Attribute attr) { | ||
if (groupAttribute.id().equals(attr.id())) { | ||
if (sourceGroupAttribute.id().equals(attr.id())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sourceGroupAttribute == groupAttribute
for anything not using Categorize. So, how was this failing for non-Categorize cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line I just updated for alignment with the rest. It's the change below that actually fixes things.
if (groupAttribute.semanticEquals(a.toAttribute())) { | ||
groupAttribute = attr; | ||
if (sourceGroupAttribute.semanticEquals(a.toAttribute())) { | ||
sourceGroupAttribute = attr; | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The groupAttribute
was mutated, but we use the sourceGroupAttribute
to determine the right channel to pass to the groupSpecs
. We need to mutate the sourceGroupAttribute
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, good catch @alex-spies
I think this will be fixed as well #117861
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks for quickly finding the issue!
The
I think it's better to have this fix in + un-skip the tests, esp. since the affected code path should only matter to 8.11/8.12; therefore, I'll try to re-run the CI without full bwc; it already passed the bwc checks for everything except 8.15. |
Forward-port of #117832 Only really relevant for bwc with 8.11/8.12.; port for consistency with 8.x
Fix #117770
Fix #117784
#117699 made changes to how we plan aggregations which were supposed to only trigger when a query contained a
CATEGORIZE
, but accidentally changed a code path that seems to only be required for interoperability with pre-8.13 nodes. Because of this, we didn't notice failing tests until the periodic bwc tests ran.The code this PR fixes addresses situations where
Aggregate
plan nodes contained aliases inside the aggregates. Onmain
and8.x
, this is effectively an illegal state: since #104958, aliases in the aggregates becomeEval
nodes before and after theAggregate
node.But here, on 8.x, we'll just fix this code path so that it behaves exactly as before #117699.
If this passes the full-bwc test, I plan to forward-port this by removing the obsolete code path on
main
.