Skip to content
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

Add semantic_text to mapping_all_types and switch to TranslationAware in PushFiltersToSource #118982

Merged
merged 4 commits into from
Jan 7, 2025

Conversation

ioanatia
Copy link
Contributor

tracked in #115103

Follow up on a few things that have not been addressed as part of these PRs:

#118355 (comment)
#118676 (comment)

@ioanatia ioanatia added >non-issue auto-backport Automatically create backport pull requests when merged :Analytics/ES|QL AKA ESQL v8.18.0 labels Dec 18, 2024
@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Dec 18, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

} else if (exp instanceof Term term) {
return term.field() instanceof FieldAttribute && DataType.isString(term.field().dataType());
} else if (exp instanceof FullTextFunction) {
} else if (exp instanceof TranslationAware) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. remove the check for Term - the same way we removed it for Match. This check is not needed since Term (the same as Match) implements the Validatable interface.
  2. use TranslationAware instead of FullTextFunction. In the initial proposal TranslationAware has a boolean translatable() method. We don't have that yet - this is also a check at the data node level and we expect that if a TranslationAware expression cannot be pushed down, that would have been caught much earlier at the verifier level.

Copy link
Member

Choose a reason for hiding this comment

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

If we're not using yet TranslationAware directly in the codebase, why make this change? 🤔

For me it's good to keep using FullTextFunction until TranslationAware is effectively used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TranslationAware is effectively used:

public abstract class FullTextFunction extends Function implements TranslationAware {

what we don't have is that boolean translatable() method and I think for now we don't need it, but we might in the future 🤷‍♀️

Copy link
Member

Choose a reason for hiding this comment

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

what we don't have is that boolean translatable() method and I think for now we don't need it, but we might in the future 🤷‍♀️

sorry, that's what I meant - we just have the interface as a marker and the interface method is not actually used. I don't see the advantage on making the switch until the interface method is actually used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay - I can revert this for now - no issue - and we'll come back to it later

},
"semantic_text": {
"type": "semantic_text",
"inference_id": "foo_inference_id"
Copy link
Member

Choose a reason for hiding this comment

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

❤️

} else if (exp instanceof Term term) {
return term.field() instanceof FieldAttribute && DataType.isString(term.field().dataType());
} else if (exp instanceof FullTextFunction) {
} else if (exp instanceof TranslationAware) {
Copy link
Member

Choose a reason for hiding this comment

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

If we're not using yet TranslationAware directly in the codebase, why make this change? 🤔

For me it's good to keep using FullTextFunction until TranslationAware is effectively used.

@ioanatia
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Contributor

@luigidellaquila luigidellaquila left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@@ -252,8 +251,6 @@ static boolean canPushToSource(Expression exp, LucenePushdownPredicates lucenePu
&& Expressions.foldable(cidrMatch.matches());
} else if (exp instanceof SpatialRelatesFunction spatial) {
return canPushSpatialFunctionToSource(spatial, lucenePushdownPredicates);
} else if (exp instanceof Term term) {
return term.field() instanceof FieldAttribute && DataType.isString(term.field().dataType());
Copy link
Contributor

Choose a reason for hiding this comment

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

This was redundant indeed, I tried it quickly and it works fine (the verifier prevents these cases).

nit: If you have a chance, it would be good to have a VerifierTest that checks that things like WHERE term("foo", "bar") return the right verification exception and don't result in a wrong pushdown.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is already tested:

private static void addNonFieldTestCase(
List<DataType> paramDataTypes,
List<Set<DataType>> supportedPerPosition,
List<TestCaseSupplier> suppliers
) {
// Negative case - use directly the field parameter type
suppliers.add(
new TestCaseSupplier(
getTestCaseName(paramDataTypes, "-non ES field"),
paramDataTypes,
typeErrorSupplier(true, supportedPerPosition, paramDataTypes, TermTests::matchTypeErrorSupplier)
)
);
}

@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
8.x

ioanatia added a commit to ioanatia/elasticsearch that referenced this pull request Jan 7, 2025
… in PushFiltersToSource (elastic#118982)

* Add semantic_text to mapping-all-types.json and switch to TranslationAware in PushFiltersToSource

* Continue to use FullTextFunction for now

---------

Co-authored-by: Elastic Machine <[email protected]>
elasticsearchmachine pushed a commit that referenced this pull request Jan 7, 2025
… in PushFiltersToSource (#118982) (#119635)

* Add semantic_text to mapping-all-types.json and switch to TranslationAware in PushFiltersToSource

* Continue to use FullTextFunction for now

---------

Co-authored-by: Elastic Machine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/ES|QL AKA ESQL auto-backport Automatically create backport pull requests when merged >non-issue Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v8.18.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants