opensearch-project / opensearch-project/sql

[FEATURE] Support batch friendly sort merge join

Open
#4,070 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

calcite enhancement PPL
Dominant language
Java
Stars
176
Forks
229
Avg merge
2d 21h
Merged PRs (30d)
43

Description

Is your feature request related to a problem?
The current logic of EnumerableMergeJoin in Calcite is retrieving all match rows for both side, and making Cartesian Product for them.

In some cases when the cardinality of the join key is very low, retrieving all rows with the same value on join key means fetching several batches from the index. However, since we always have query_size_limit in the end of PPL query or users may have their own limitation, and low cardinality means plenty of data explosion, the Cartesian Product of the first batch will usually satisfy the limit. Fetching batches more than requirements brings more query latency and memory usage.

What solution would you like?
Implements batch friendly sort merge join.

What alternatives have you considered?
A clear and concise description of any alternative solutions or features you've considered.

Do you have any additional context?
Add any other context or screenshots about the feature request here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing Calcite's EnumerableMergeJoin implementation and how OpenSearch SQL handles query_size_limit and index batches. Investigate the current retrieval of matching rows on both sides and its Cartesian-product behavior. Done means implementing a batch-friendly sort merge join that avoids unnecessary batch fetching while still satisfying the query limit.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend-api-design, databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.