Skip to content

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

Merged
ioanatia merged 4 commits intoelastic:mainfrom
ioanatia:semantic_text_esql_follow_up
Jan 7, 2025
Merged

Add semantic_text to mapping_all_types and switch to TranslationAware in PushFiltersToSource#118982
ioanatia merged 4 commits intoelastic:mainfrom
ioanatia:semantic_text_esql_follow_up

Conversation

@ioanatia
Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
Member 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
Copy Markdown
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
Copy Markdown
Member 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
Copy Markdown
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
Copy Markdown
Member 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member Author

@elasticmachine merge upstream

Copy link
Copy Markdown
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!

} 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
Copy Markdown
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
Copy Markdown
Member 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
Copy Markdown
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 <elasticmachine@users.noreply.github.com>
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 <elasticmachine@users.noreply.github.com>
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