Skip to content

Added support for DSL Exists query to convert in RelNode format#1

Open
abhishek00159 wants to merge 3 commits intovinaykpud:feature/datafusion-dslfrom
abhishek00159:feature/datafusion-dsl
Open

Added support for DSL Exists query to convert in RelNode format#1
abhishek00159 wants to merge 3 commits intovinaykpud:feature/datafusion-dslfrom
abhishek00159:feature/datafusion-dsl

Conversation

@abhishek00159
Copy link
Copy Markdown

Description

Implements the QueryTranslator interface to convert OpenSearch ExistsQueryBuilder to Calcite IS NOT NULL RexNode.

1. Created ExistsQueryTranslator

Key Logic:

  • Extracts field name from ExistsQueryBuilder
  • Looks up field in schema to get field index and throw exception if boost is passed with not default value or field is not passed.
  • Creates IS NOT NULL($fieldIndex) RexNode using Calcite's SqlStdOperatorTable.IS_NOT_NULL

Calcite Output:

LogicalFilter(condition=[IS NOT NULL($N)])
  LogicalTableScan(table=[[index-name]])

2. Registered ExistsQueryTranslator

File: src/main/java/org/opensearch/dsl/query/QueryRegistryFactory.java

Added registration in the create() method:

registry.register(new ExistsQueryTranslator());

This makes the translator available for all exists queries.

3. Added Integration Tests

File: src/internalClusterTest/java/org/opensearch/dsl/DslLogicalPlanIntegrationIT.java

Added three comprehensive tests.

  1. Exists query test
  2. Exists query with bool.
  3. Exist query not supported for boost.

Related Issues

Resolves #[Issue number to be closed when this PR is merged]
NA

Check List

  • [Done ] Functionality includes testing.
  • [NA ] API changes companion pull request created, if applicable.
  • [ NA] Public documentation issue/PR created, if applicable.

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.

Copy link
Copy Markdown

@nssuresh2007 nssuresh2007 left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants