Skip to content

Commit

Permalink
feat: new limit and offset methods on SubstraitBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
vbarua committed Apr 26, 2024
1 parent 572fe57 commit a3905e6
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions core/src/main/java/io/substrait/dsl/SubstraitBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.OptionalLong;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
Expand Down Expand Up @@ -109,14 +110,30 @@ private Cross cross(Rel left, Rel right, Optional<Rel.Remap> remap) {
}

public Fetch fetch(long offset, long count, Rel input) {
return fetch(offset, count, Optional.empty(), input);
return fetch(offset, OptionalLong.of(count), Optional.empty(), input);
}

public Fetch fetch(long offset, long count, Rel.Remap remap, Rel input) {
return fetch(offset, count, Optional.of(remap), input);
return fetch(offset, OptionalLong.of(count), Optional.of(remap), input);
}

private Fetch fetch(long offset, long count, Optional<Rel.Remap> remap, Rel input) {
public Fetch limit(long limit, Rel input) {
return fetch(0, OptionalLong.of(limit), Optional.empty(), input);
}

public Fetch limit(long limit, Rel.Remap remap, Rel input) {
return fetch(0, OptionalLong.of(limit), Optional.of(remap), input);
}

public Fetch offset(long offset, Rel input) {
return fetch(offset, OptionalLong.empty(), Optional.empty(), input);
}

public Fetch offset(long offset, Rel.Remap remap, Rel input) {
return fetch(offset, OptionalLong.empty(), Optional.of(remap), input);
}

private Fetch fetch(long offset, OptionalLong count, Optional<Rel.Remap> remap, Rel input) {
return Fetch.builder().offset(offset).count(count).input(input).remap(remap).build();
}

Expand Down

0 comments on commit a3905e6

Please sign in to comment.