Skip to content

Commit

Permalink
split add method for ArrowRel.Implementor
Browse files Browse the repository at this point in the history
  • Loading branch information
asolimando committed Feb 27, 2024
1 parent c50e955 commit d3b69d9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ class ArrowFilter extends Filter implements ArrowRel {

@Override public void implement(Implementor implementor) {
implementor.visitInput(0, getInput());
implementor.add(null, match);
implementor.addFilters(match);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ class ArrowProject extends Project implements ArrowRel {

@Override public void implement(Implementor implementor) {
implementor.visitInput(0, getInput());
implementor.add(getProjectFields(getProjects()), null);
List<Integer> projectedFields = getProjectFields(getProjects());
if (projectedFields != null) {
implementor.addProjectFields(projectedFields);
}
}

static @Nullable List<Integer> getProjectFields(List<RexNode> exps) {
Expand Down
20 changes: 11 additions & 9 deletions arrow/src/main/java/org/apache/calcite/adapter/arrow/ArrowRel.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,20 @@ class Implementor {
@Nullable RelOptTable table;
@Nullable ArrowTable arrowTable;

/** Adds newly projected fields and restricted predicates.
/** Adds new predicates.
*
* @param fields New fields to be projected from a query
* @param predicates Predicates
*/
void add(@Nullable List<Integer> fields, @Nullable List<String> predicates) {
if (fields != null) {
selectFields = ImmutableIntList.copyOf(fields);
}
if (predicates != null) {
whereClause.addAll(predicates);
}
void addFilters(List<String> predicates) {
whereClause.addAll(predicates);
}

/** Adds newly projected fields.
*
* @param fields New fields to be projected from a query
*/
void addProjectFields(List<Integer> fields) {
selectFields = ImmutableIntList.copyOf(fields);
}

public void visitInput(int ordinal, RelNode input) {
Expand Down

0 comments on commit d3b69d9

Please sign in to comment.