Skip to content

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

Merged
merged 4 commits into from
Aug 12, 2023

Conversation

bpintea
Copy link
Contributor

@bpintea bpintea commented Aug 10, 2023

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.
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-ql (Team:QL)

QL spotless
@bpintea bpintea removed the v8.10.0 label Aug 10, 2023
@@ -7,7 +7,6 @@

package org.elasticsearch.xpack.esql.analysis;

import org.elasticsearch.xpack.esql.expression.MetadataAttribute;
Copy link
Contributor Author

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
Copy link
Contributor Author

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;
Copy link
Contributor Author

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.

Copy link
Member

@costin costin left a 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) {
Copy link
Member

Choose a reason for hiding this comment

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

How about isPushableAttribute?

Copy link
Contributor Author

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 + "]");
Copy link
Member

Choose a reason for hiding this comment

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

Use EsqlIllegalArgument instead.

Comment on lines 53 to 59
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();
}
Copy link
Member

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()

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/elasticsearch-esql (:Query Languages/ES|QL)

@bpintea
Copy link
Contributor Author

bpintea commented Aug 11, 2023

@elasticsearchmachine run elasticsearch-ci/part-2

@bpintea bpintea merged commit 6cd0578 into elastic:feature/esql Aug 12, 2023
@bpintea bpintea deleted the esql/push_metadata branch August 12, 2023 09:48
csoulios pushed a commit to csoulios/elasticsearch that referenced this pull request Aug 18, 2023
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/ES|QL AKA ESQL >enhancement Team:QL (Deprecated) Meta label for query languages team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants