File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
core/src/main/java/org/opensearch/sql/calcite/utils Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff 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 *
You can’t perform that action at this time.
0 commit comments