Skip to content

Conversation

@qianheng-aws
Copy link
Collaborator

@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.

Signed-off-by: Heng Qian <qianheng@amazon.com>
Signed-off-by: Heng Qian <qianheng@amazon.com>
Signed-off-by: Heng Qian <qianheng@amazon.com>
Signed-off-by: Heng Qian <qianheng@amazon.com>
RexInputRef ref, List<String> schema, Map<String, OpenSearchDataType> typeMapping) {
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
Collaborator 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
Collaborator 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.

Signed-off-by: Heng Qian <qianheng@amazon.com>
@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
penghuo pushed a commit to penghuo/os-sql that referenced this pull request Mar 12, 2025
…3376)

* [BugFix] Fix text field push down

Signed-off-by: Heng Qian <qianheng@amazon.com>

* Ignore CalciteSortCommandIT.testSortWithNullValue

Signed-off-by: Heng Qian <qianheng@amazon.com>

* Refine code: only get keyword subfield for termQuery builder

Signed-off-by: Heng Qian <qianheng@amazon.com>

* Refine code

Signed-off-by: Heng Qian <qianheng@amazon.com>

* remove ignore tests in CalcitePPLInSubqueryIT

Signed-off-by: Heng Qian <qianheng@amazon.com>

---------

Signed-off-by: Heng Qian <qianheng@amazon.com>
penghuo pushed a commit that referenced this pull request Jun 16, 2025
* [BugFix] Fix text field push down

Signed-off-by: Heng Qian <qianheng@amazon.com>

* Ignore CalciteSortCommandIT.testSortWithNullValue

Signed-off-by: Heng Qian <qianheng@amazon.com>

* Refine code: only get keyword subfield for termQuery builder

Signed-off-by: Heng Qian <qianheng@amazon.com>

* Refine code

Signed-off-by: Heng Qian <qianheng@amazon.com>

* remove ignore tests in CalcitePPLInSubqueryIT

Signed-off-by: Heng Qian <qianheng@amazon.com>

---------

Signed-off-by: Heng Qian <qianheng@amazon.com>
Signed-off-by: xinyual <xinyual@amazon.com>
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