-
Notifications
You must be signed in to change notification settings - Fork 25.2k
ESQL: Pushdown metadata attributes #98355
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 allows to push down those metadata attributes that can be pushed down. Out of the currently supported three, the only one pushed down is _index. This only supports wildcard and terms queries.
Pinging @elastic/es-ql (Team:QL) |
@@ -7,7 +7,6 @@ | |||
|
|||
package org.elasticsearch.xpack.esql.analysis; | |||
|
|||
import org.elasticsearch.xpack.esql.expression.MetadataAttribute; |
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.
Spotless rearrangements (possibly due to repo's rules).
"_index", | ||
tuple(DataTypes.KEYWORD, true), | ||
"_id", | ||
tuple(DataTypes.KEYWORD, false) | ||
tuple(DataTypes.KEYWORD, false) // actually searchable, but fielddata access on the _id field is disallowed by default |
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.
The _id
could be pushed down, but since by default it would return an error, pushing down is disabled. This does mean however that those deployments with fielddata accessible are taxed.
); | ||
|
||
private final boolean docValues; |
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.
docValues
was added for future _id
support. However, _id
support matches by name, not by checking if the attribute has or not docValues
; so scrapped and replaced with searchable
.
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
} else if (exp instanceof Not not) { | ||
return canPushToSource(not.field()); | ||
} | ||
return false; | ||
} | ||
|
||
private static boolean canPushAttribute(Expression expression, ScalarFunction operation) { |
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 about isPushableAttribute
?
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.
Replaced (with isAttributePushable)
.
if (field instanceof MetadataAttribute) { | ||
return querySupplier.get(); // MetadataAttributes are always single valued | ||
} | ||
throw new IllegalStateException("Expected a FieldAttribute or MetadataAttribute but received [" + field + "]"); |
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.
Use EsqlIllegalArgument instead.
public static String pushableAttributeName(TypedAttribute attribute) { | ||
if (attribute instanceof FieldAttribute fa) { | ||
// equality should always be against an exact match (which is important for strings) | ||
return fa.exactAttribute().name(); | ||
} | ||
return attribute.name(); | ||
} |
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.
Ternary operator ftw:
return (attribute instanceof FieldAttribute fa) ? fa.exactAttribute().name() : attribute.name()
Renamings and reformatting.
Pinging @elastic/elasticsearch-esql (:Query Languages/ES|QL) |
@elasticsearchmachine run elasticsearch-ci/part-2 |
This allows to push down those metadata attributes that can be pushed down. Out of the currently supported three, the only one pushed down is _index. This only supports wildcard and terms queries.
This allows to push down those metadata attributes that can be pushed down.
Out of the currently supported three, the only one pushed down is
_index
. This only supports wildcard and terms queries.