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

[BugFix] support push down text field correctly. #3376

Conversation

qianheng-aws
Copy link
Contributor

@qianheng-aws qianheng-aws commented Mar 4, 2025

Description

When pushing filter with text field, I should construct QueryBuilder by using its subfield of keyword type; Otherwise, we cannot push down this field.

This PR includes change:

  1. In PredicateAnalyzer, using keyword subfield as the reference for NamedFieldExpression if it's type is text type. It will return null if no such keyword subfield and throw PredicateAnalyzerException, and then scan won't really do filter push down later.
  2. remove the @ignore annotation for CalciteSortCommandIT since we already addressed the issue of order perseverance for PPL in this PR: Fix execution errors caused by plan gap #3350.

./gradlew :integ-test:integTest --tests '*Calcite*IT' succeed locally.

Related Issues

Resolves #3334, #3373

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.

this.name =
(ref == null || ref.getIndex() >= schema.size()) ? null : schema.get(ref.getIndex());
this.type = typeMapping.get(name);
Copy link
Member

Choose a reason for hiding this comment

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

NPE if typeMapping is null

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It won't return null for this map from the source, see

public Map<String, OpenSearchDataType> getFieldOpenSearchTypes() {
.

return type;
}

boolean isTextType() {
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 change to notKeyword(), isTextType looks specific purpose

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 don't know if there is other case like Text type where we need to find keyword subfield.

There is similar specific method name in flint, https://github.com/opensearch-project/opensearch-spark/blob/c0c315f010fc1ef4606964e6b34a8ba6fb79949e/flint-spark-integration/src/main/scala/org/apache/spark/sql/flint/storage/FlintQueryCompiler.scala#L208, maybe just follow it.

@LantaoJin LantaoJin merged commit fa63b23 into opensearch-project:feature/calcite-engine Mar 4, 2025
5 of 13 checks passed
@LantaoJin LantaoJin added the calcite calcite migration releated label Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
calcite calcite migration releated
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants