Add ESQL View as an IndexAbstraction#139778
Conversation
6434f70 to
4a43dd1
Compare
03d42b6 to
4656e6d
Compare
This commit adds the `View` class as the fourth `IndexAbstraction`. This means that it can be "resolved" in the expression resolver, and moves us towards implementing the ES security model for views. It also includes code that prevents conflicting views, indices, aliases, and data streams with the same name. Additionally, we prevent indexing into a view or directly resolving it for a search (if someone searches for `*` for instance). Relates to elastic#137818
4656e6d to
c0316f7
Compare
|
Pinging @elastic/es-data-management (Team:Data Management) |
| assertThat( | ||
| e.getMessage(), | ||
| equalTo("Invalid alias name [logs]: an index or data stream exists with the same name as the alias") | ||
| equalTo("Invalid alias name [logs]: an index, data stream, or ESQL view exists with the same name as the alias") |
There was a problem hiding this comment.
Nit: considering that this is a user facing message, do we need to write ES|QL instead of ESQL?
There was a problem hiding this comment.
I've seen a mixture of both in the codebase, but I found more using "ESQL" than "ES|QL", so I went with this one.
server/src/main/java/org/elasticsearch/cluster/metadata/ProjectMetadata.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/cluster/metadata/IndexNameExpressionResolver.java
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/cluster/metadata/IndexAbstraction.java
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/cluster/metadata/View.java
Outdated
Show resolved
Hide resolved
| throw new IllegalArgumentException("cannot add view, the maximum number of views is reached: " + this.maxViewsCount); | ||
| } | ||
|
|
||
| final Map<String, IndexAbstraction> indicesLookup = getIndicesLookup(metadata); |
There was a problem hiding this comment.
I see this logic is used to check naming collision for views against all other types. Why can't we use it elsewhere? I wonder if it could be a method in ProjectMetadata....that would make also collision logic easier to test.
There was a problem hiding this comment.
I opened #140131 for tracking unifying the name collision work. I agree that it definitely can be improved in subsequent work.
craigtaverner
left a comment
There was a problem hiding this comment.
Nice improvement. Great that name conflict checks appear to be implemented in both directions. There was a loose end in the TestCluster around wiping views, but other than that this looks good to me.
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/view/RestPutViewAction.java
Show resolved
Hide resolved
x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/200_view.yml
Show resolved
Hide resolved
* Add ESQL View as an IndexAbstraction This commit adds the `View` class as the fourth `IndexAbstraction`. This means that it can be "resolved" in the expression resolver, and moves us towards implementing the ES security model for views. It also includes code that prevents conflicting views, indices, aliases, and data streams with the same name. Additionally, we prevent indexing into a view or directly resolving it for a search (if someone searches for `*` for instance). Relates to elastic#137818 * Include views in comment * Add earlier filtering of views in IndexNameExpressionResolver * Use empty list of indices and null write index for View
This commit adds the
Viewclass as the fourthIndexAbstraction. This means that it can be"resolved" in the expression resolver, and moves us towards implementing the ES security model for
views. It also includes code that prevents conflicting views, indices, aliases, and data streams
with the same name. Additionally, we prevent indexing into a view or directly resolving it for a
search (if someone searches for
*for instance).Relates to #137818