- Notifications
You must be signed in to change notification settings - Fork 25.6k
ESQL: Fix columns ordering when pruning an INLINE STATS #136827
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
Conversation
This fixes the incorrect ordering of the columns that can occur when INLINE STATS is pruned entirely, due to its calculated value being discarded (dropped or overshadowned)
| Pinging @elastic/es-analytical-engine (Team:Analytics) |
| Hi @bpintea, I've created a changelog YAML for you. |
astefan left a comment
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. Left some minor comments, except the one with projection.
Also, I would add some variations to stats computations keepers and droppers:
ROW a = null, b = 0, c = "x", d = 1 | INLINE STATS a = MAX(c), d = MIN(c), e = AVG(b) by b | EVAL a = c, d = 2 ROW a = null, b = 0, c = "x", d = 1 | INLINE STATS a = MAX(c), d = MIN(c), e = AVG(b), a = MIN(b) by b | EVAL a = c, d = 2 ROW a = null, b = 0, c = "x", d = 1 | INLINE STATS a = MAX(c), d = MIN(c), e = AVG(b), a = MIN(b), f = MAX(b) by b | EVAL a = c, d = 2 | /** | ||
| * Fix pruning of columns when shadowed in INLINE STATS | ||
| */ | ||
| INLINE_STATS_PRUNE_COLUMN_FIX(INLINESTATS_V11.enabled), |
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.
| INLINE_STATS_PRUNE_COLUMN_FIX(INLINESTATS_V11.enabled), | |
| INLINE_STATS_PRUNE_COLUMN_FIX(INLINE_STATS.enabled), |
| List<Attribute> newOutput = new ArrayList<>(ij.output()); | ||
| AttributeSet leftOutputSet = ij.left().outputSet(); | ||
| newOutput.removeIf(attr -> leftOutputSet.contains(attr) == false); | ||
| p = new EsqlProject(ij.source(), ij.left(), newOutput); |
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.
| p = new EsqlProject(ij.source(), ij.left(), newOutput); | |
| p = new Project(ij.source(), ij.left(), newOutput); |
| var right = pruneColumns(ij.right(), used, true); | ||
| if (right.output().isEmpty() || isLocalEmptyRelation(right)) { | ||
| p = ij.left(); | ||
| // InlineJoin updates the order of the output, so even if the computation is dropped, the groups need to be pulled to the end |
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.
I think this comment is putting an emphasis on re-ordering of the output elements, but in reality it's filtering the output based on the elements which are not needed anymore. The ordering is the same, only that some elements are filtered out.
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.
I've supplemented the comment.
| Thanks, Andrei.
I've added them, though with small completions, since all the computed values need to be overwritten -- only then does the bug show. |
💔 Backport failed
You can use sqren/backport to manually backport by running |
This fixes the incorrect ordering of the columns that can occur when INLINE STATS is pruned entirely, due to its calculated value being discarded (overshadowed). Fixes elastic#136797
This fixes the incorrect ordering of the columns that can occur when INLINE STATS is pruned entirely, due to its calculated value being discarded (overshadowed).
Fixes #136797