Skip to content

Fix error when pushing down script filter with struct field #3693

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 6 commits into from
Jun 11, 2025

Conversation

qianheng-aws
Copy link
Collaborator

@qianheng-aws qianheng-aws commented May 28, 2025

Description

Fix error when pushing down script filter with struct field. This bug only happens in v2 engine, since calcite engine doesn't support script pushing down currently.

It's caused by that the FilterScript::getDoc only provides the capability of looking up leaf node, thus it will throw exception No field found for [xxx] in mapping when using fields of struct type. We could address this issue by preventing push down script filter with fields of struct type.

https://github.com/opensearch-project/OpenSearch/blob/9bca961b799625438d024491320323b310dc531f/server/src/main/java/org/opensearch/script/FilterScript.java#L73

Related Issues

Resolves #3312

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • New functionality has javadoc added.
  • New functionality has a user manual doc added.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Heng Qian <[email protected]>
@qianheng-aws qianheng-aws added the bug Something isn't working label May 28, 2025
LantaoJin
LantaoJin previously approved these changes May 29, 2025
if (LOG.isDebugEnabled()) {
LOG.debug("Cannot pushdown the filter condition: {}", queryCondition, e);
} else {
LOG.info("Cannot pushdown the filter condition: {}, ", queryCondition);
Copy link
Collaborator

Choose a reason for hiding this comment

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

sanitize queryCondition before logging.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do you mean anonymizing the queryCondition by using PPLQueryDataAnonymizer?

I think, after anonymizing, we cannot get any useful information from the log. If it's not allowed to show that information in log, maybe we should remove queryCondition here directly.

Copy link
Collaborator Author

@qianheng-aws qianheng-aws Jun 10, 2025

Choose a reason for hiding this comment

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

Or maybe only keep debug level log and keep queryCondition in debug log. Does it make sense? What's your opinion? @penghuo

Copy link
Collaborator

Choose a reason for hiding this comment

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

queryCondtion include user meta data, we should not log it. remove it

Signed-off-by: Heng Qian <[email protected]>
…tField

# Conflicts:
#	integ-test/src/test/resources/expectedOutput/ppl/explain_patterns_agg_push.json
penghuo
penghuo previously approved these changes Jun 11, 2025
Signed-off-by: Heng Qian <[email protected]>
@qianheng-aws qianheng-aws requested a review from penghuo June 11, 2025 05:37
@penghuo penghuo merged commit 0f197e5 into opensearch-project:main Jun 11, 2025
22 checks passed
penghuo pushed a commit that referenced this pull request Jun 16, 2025
* Fix error when pushing down script filter with struct field

Signed-off-by: Heng Qian <[email protected]>

* Fix IT

Signed-off-by: Heng Qian <[email protected]>

* Address comments

Signed-off-by: Heng Qian <[email protected]>

* Fix IT

Signed-off-by: Heng Qian <[email protected]>

---------

Signed-off-by: Heng Qian <[email protected]>
Signed-off-by: xinyual <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Null functions with struct field
3 participants