Add Terms Query Support for Calcite RelNode Conversion#2
Open
abhishek00159 wants to merge 3 commits intovinaykpud:feature/datafusion-dslfrom
Open
Add Terms Query Support for Calcite RelNode Conversion#2abhishek00159 wants to merge 3 commits intovinaykpud:feature/datafusion-dslfrom
abhishek00159 wants to merge 3 commits intovinaykpud:feature/datafusion-dslfrom
Conversation
| TermsQueryBuilder termsQuery = (TermsQueryBuilder) query; | ||
|
|
||
| if (termsQuery.boost() != AbstractQueryBuilder.DEFAULT_BOOST) { | ||
| throw new RuntimeException("Terms query does not support non-default boost"); |
There was a problem hiding this comment.
We need to throw ConversionException to follow the same convention used in other places
Comment on lines
+156
to
+159
| String indexName = "test-terms-valuetype"; | ||
| String mapping = "{\"properties\": {\"category\": {\"type\": \"keyword\"}}}"; | ||
| client().admin().indices().prepareCreate(indexName).setMapping(mapping).get(); | ||
| ensureGreen(indexName); |
There was a problem hiding this comment.
Can this be done in the setup method of IT instead of every method?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for converting OpenSearch terms queries into Calcite RelNode format, enabling the query-dsl-calcite plugin to handle multi-value equality checks.
Changes
• New Translator: Implemented TermsQueryTranslator that converts TermsQueryBuilder to Calcite SEARCH(IN) operator
• Registration: Added the new translator to QueryRegistryFactory
• Documentation: Updated README with terms query mapping (terms → SEARCH($field, value1, value2, ...))
• Tests: Added comprehensive integration tests covering:
• Basic terms query conversion
• Validation for unsupported boost parameter
• Validation for unsupported _name parameter
• Validation for unsupported value_type parameter
Technical Details
The TermsQueryTranslator converts a terms query like:
json
{
"terms": {
"category": ["electronics", "computers", "laptops"]
}
}
Into a Calcite logical plan:
LogicalFilter(condition=[SEARCH($0, Sarg['electronics':VARCHAR, 'furniture':VARCHAR]:VARCHAR)])
LogicalTableScan(table=[[products]])
Testing:
Output:
Validation
The implementation enforces that only default values are used for boost, query name, and value type parameters, throwing exceptions for unsupported configurations.
Check List
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.