lyne7-sc opened a new issue, #2463:
URL: https://github.com/apache/auron/issues/2463
**Describe the bug**
<!--
A clear and concise description of what the bug is.
-->
Native Top-K queries may fail when all output columns are also sort keys.
In this case, the sort keys are stored separately and the data batch
contains no columns. The sorted indices are truncated by the Top-K limit, but
the zero-column batch still keeps the original input row count.
This row-count mismatch can cause the merge cursor to read past the retained
sort-key rows.
**To Reproduce**
<!--
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
-->
Run a Top-K query whose output contains only the sort column:
```scala
spark
.range(10)
.repartition(1)
.select("id")
.orderBy("id")
.limit(6)
.collect()
```
The query fails in native `SortExec` with:
```text
unsafe precondition(s) violated:
slice::get_unchecked requires that the index is within the slice
```
**Expected behavior**
<!--
A clear and concise description of what you expected to happen.
-->
The query should return the correct result.
**Screenshots**
<!--
If applicable, add screenshots to help explain your problem.
-->
**Additional context**
<!--
Add any other context about the problem here.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]