opensearch-project / opensearch-project/sql

[BUG] `LIMIT` works incorrectly with `NESTED`

Open
#1,764 1 comment 0 reactions 1 assignee View on GitHub

@forestmvey is already working on this.

Since Jun 22, 2023.

bug SQL
Dominant language
Java
Stars
176
Forks
229
Avg merge
2d 21h
Merged PRs (30d)
43

Description

What is the bug?
https://github.com/Bit-Quill/opensearch-project-sql/pull/278#issuecomment-1599332365
A query with LIMIT N and NESTED function may return M rows, where M > N.

How can one reproduce the bug?
https://github.com/Bit-Quill/opensearch-project-sql/pull/278#issuecomment-1599332365
Being pushed down LIMIT defines number of docs to be returned, but NestedOperator adds extra rows while processes cartesian products.

What is the expected behavior?
Keep LIMIT pushed down, but leave LogicalLimit/LimitOperator in the plan tree to count number of the rows returned and cut off when limit reached.
Depends on Optimizer rework presented in #1752.

What is your host/environment?
main @ ded014d1

Do you have any screenshots?
N/A

Do you have any additional context?
N/A

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.