Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void open() {
super.open();

// skip the leading rows of offset size
while (input.hasNext() && count < offset) {
while (count < offset && input.hasNext()) {
count++;
input.next();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.opensearch.sql.data.type.ExprCoreType.INTEGER;

import com.google.common.collect.ImmutableMap;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.opensearch.sql.data.model.ExprValue;
import org.opensearch.sql.data.model.ExprValueUtils;
import org.opensearch.sql.expression.DSL;

public class LimitOperatorTest extends PhysicalPlanTestBase {

Expand Down Expand Up @@ -63,4 +65,15 @@ public void offset_exceeds_row_number() {
List<ExprValue> result = execute(plan);
assertEquals(0, result.size());
}

@Test
public void zero_offset_limit_does_not_skip_first_deduplicated_row() {
PhysicalPlan dedupe = new DedupeOperator(new TestScan(), List.of(DSL.ref("response", INTEGER)));
PhysicalPlan plan = new LimitOperator(dedupe, 500, 0);

List<ExprValue> result = execute(plan);

assertEquals(3, result.size());
assertEquals(200, result.get(0).tupleValue().get("response").integerValue());
}
}
Loading