Skip to content

Add support for non exhaustive variants #1662

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

Merged
merged 4 commits into from
Apr 27, 2022
Merged

Add support for non exhaustive variants #1662

merged 4 commits into from
Apr 27, 2022

Conversation

swallez
Copy link
Member

@swallez swallez commented Apr 26, 2022

Elasticsearch plugins can add new implementations for a significant number of components, such as for example queries, aggregations and property types.

This PR adds an additional @non_exhaustive annotation (term borrowed from Rust's equivalent feature) that can be added to @variants types and enums (see below) to capture the fact that variants or enum members not present in the spec can exist, and clients should allow that.

This PR also adds the new @non_exhaustive annotation to the relevant types, found from the plugin interface definitions in the ES code base.

Example:

/**
 * @variants container
 * @non_exhaustive
 */
export class QueryContainer {
  ...
}

The following pluggable components were left out from this PR as they require a bit more investigation in their specification: highlighters, score functions, significance heuristics.

enums: for consistency this PR also changes @open_enum for open enumerations to @non_exhaustive. The enum metamodel isn't changed, and this annotation still sets the isOpen property.

Related: Java implementation of @non_exhaustive: elastic/elasticsearch-java#252

@swallez swallez changed the title Add support for open variants Add support for non exhaustive variants Apr 26, 2022
@github-actions
Copy link
Contributor

Following you can find the validation results for the APIs you have changed.

API Status Request Response
ingest.delete_pipeline 🟢 11/11 11/11
ingest.geo_ip_stats Missing test Missing test
ingest.get_pipeline 🟢 22/22 22/22
ingest.processor_grok 🟢 1/1 1/1
ingest.put_pipeline 🟢 30/30 30/30
ingest.simulate 🟢 4/4 4/4
search 🔴 1492/1526 1505/1508

You can validate these APIs yourself by using the make validate target.

Copy link
Contributor

@sethmlarson sethmlarson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is super great, love what's been done with @open_enum to make everything even more consistent!

@swallez swallez merged commit 7c3d1ce into main Apr 27, 2022
@swallez swallez deleted the open-variants branch April 27, 2022 09:12
@github-actions
Copy link
Contributor

The backport to 7.17 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-7.17 7.17
# Navigate to the new working tree
cd .worktrees/backport-7.17
# Create a new branch
git switch --create backport-1662-to-7.17
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick --mainline 1 7c3d1ce0febc9d78d7e385bf5ec503fb5e3af1e1
# Push it to GitHub
git push --set-upstream origin backport-1662-to-7.17
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-7.17

Then, create a pull request where the base branch is 7.17 and the compare/head branch is backport-1662-to-7.17.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants