Skip to content

Commit 7fabbe6

Browse files
author
Selina Song
committed
restore planutils after merge
Signed-off-by: Selina Song <[email protected]>
1 parent 4343b47 commit 7fabbe6

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

core/src/main/java/org/opensearch/sql/calcite/utils/PlanUtils.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,43 @@ static RexNode derefMapCall(RexNode rexNode) {
358358
return rexNode;
359359
}
360360

361+
/** Check if contains RexOver */
362+
static boolean containsRowNumberDedup(LogicalProject project) {
363+
return project.getProjects().stream()
364+
.anyMatch(p -> p instanceof RexOver && p.getKind() == SqlKind.ROW_NUMBER);
365+
}
366+
367+
/** Get all RexWindow list from LogicalProject */
368+
static List<RexWindow> getRexWindowFromProject(LogicalProject project) {
369+
final List<RexWindow> res = new ArrayList<>();
370+
final RexVisitorImpl<Void> visitor =
371+
new RexVisitorImpl<>(true) {
372+
@Override
373+
public Void visitOver(RexOver over) {
374+
res.add(over.getWindow());
375+
return null;
376+
}
377+
};
378+
visitor.visitEach(project.getProjects());
379+
return res;
380+
}
381+
382+
static List<Integer> getSelectColumns(List<RexNode> rexNodes) {
383+
final List<Integer> selectedColumns = new ArrayList<>();
384+
final RexVisitorImpl<Void> visitor =
385+
new RexVisitorImpl<Void>(true) {
386+
@Override
387+
public Void visitInputRef(RexInputRef inputRef) {
388+
if (!selectedColumns.contains(inputRef.getIndex())) {
389+
selectedColumns.add(inputRef.getIndex());
390+
}
391+
return null;
392+
}
393+
};
394+
visitor.visitEach(rexNodes);
395+
return selectedColumns;
396+
}
397+
361398
/**
362399
* Reverses the direction of a RelCollation.
363400
*

0 commit comments

Comments
 (0)