-
Notifications
You must be signed in to change notification settings - Fork 612
[FR] Add keep metadata check to esql schema test #5441
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
base: main
Are you sure you want to change the base?
Conversation
Enhancement - GuidelinesThese guidelines serve as a reminder set of considerations when addressing adding a new schema feature to the code. Documentation and Context
Code Standards and Practices
Testing
Additional Schema Related Checks
|
|
If #5433 merges and we are fine with Updated: Complete |
Mikaayenson
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.
Maybe clarify in docs/tests that this is specifically about ensuring those metadata fields are in the output row (i.e., in keep), not just in METADATA
| ) | ||
|
|
||
| # Ensure that keep clause includes metadata fields on non-aggregate queries | ||
| aggregate_pattern = re.compile(r"\bstats\b.*\bby\b", re.IGNORECASE | re.DOTALL) |
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.
Will this catch things like | stats count(*) (no by)?
| # Match | followed by optional whitespace/newlines and then 'keep' | ||
| keep_pattern = re.compile(r"\|\s*keep\b", re.IGNORECASE | re.DOTALL) | ||
| if not keep_pattern.search(query_lower): | ||
| keep_pattern = re.compile(r"\|\s*keep\b\s+([^\|]+)", re.IGNORECASE | re.DOTALL) |
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.
How does this work with things like keep Esql.* / keep aws.*?
| raise EsqlSemanticError( | ||
| f"Rule: {data['name']} contains a keep clause without" | ||
| f" metadata fields '_id', '_version', and '_index' ->" | ||
| f" Add '_id, _version', '_index' to the keep command." |
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.
| f" Add '_id, _version', '_index' to the keep command." | |
| f" Add '_id', _version', '_index' to the keep command." |
Pull Request
Issue link(s):
Resolves #5440
Related to #5439
Summary - What I changed
I added a schema test to enforce adding metadata fields to the
keepportion of non-aggregate ES|QL queries.Note unit tests will continue to fail until the rules are updated to match the new
keeprequirement.How To Test
Use view rule on an ES|QL rule that does not have the metadata fields
_id, _version, _indexin itskeepline.E.g.
Checklist
bug,enhancement,schema,maintenance,Rule: New,Rule: Deprecation,Rule: Tuning,Hunt: New, orHunt: Tuningso guidelines can be generatedmeta:rapid-mergelabel if planning to merge within 24 hoursContributor checklist