- 
                Notifications
    
You must be signed in to change notification settings  - Fork 25.6k
 
ESQL: Fix union types lost attributes in StubRelation for inlinestats #135547
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 union types lost attributes in StubRelation for inlinestats #135547
Conversation
| 
           Hi @astefan, I've created a changelog YAML for you.  | 
    
| 
           Pinging @elastic/es-analytical-engine (Team:Analytics)  | 
    
…fix_union_types_lost_attributes
…astefan/elasticsearch into fix_union_types_lost_attributes
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
| summary: Fix union types lost attributes in `StubRelation` for inlinestats | ||
| area: ES|QL | ||
| type: bug | ||
| issues: [] | 
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.
Might have been nice to have an issue describing this more
| DENSE_VECTOR_AGG_METRIC_DOUBLE_IF_FNS | ||
| DENSE_VECTOR_AGG_METRIC_DOUBLE_IF_FNS, | ||
| 
               | 
          ||
| INLINE_STATS_WITH_UNION_TYPES_IN_STUB_RELATION(INLINE_STATS.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.
This should move up in the list to the rest of the INLINE_STATS capabilities. We try to avoid adding to the end of the capabilities, because that causes increased conflict probability. It's also nicer when exploring for all related Capabilities to be near each other.
| | INLINE STATS c = count(emp_no::long) where hire_date > "1991-01-01" BY yr | ||
| | SORT yr DESC | ||
| | LIMIT 5 | ||
| | SORT yr DESC, hire_date DESC | 
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 notice all these fixed tests involve a grouping key. Do we have tests for non-grouped inline stats?
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.
OK. I added a test here for this, and it worked. I'll push a commit for it, and if you feel that test is redundant, just revert the commit.
| 
           Thank you, @craigtaverner, for the review and updates to the PR!  | 
    
This accounts for synthetics attributes that are added as part of union types support inside
StubRelation(an essential component ofinline statssupport). StubRelation can be regarded as a source plan node (similar to EsRelation) and, thus, the synthetics attributes handling as part of union types feature should be mirrored in this "source" plan as well.To make this handling "encapsulated" and tightly linked to StubRelation, the constructor of the class has been changed so that theoutputlist of Attributes is computed only in one place and be "reused" whenever a StubRelation is created or changed.