(SqlValidator validator,
SqlValidatorScope scope)
| 605 | } |
| 606 | |
| 607 | @Override public void validate(SqlValidator validator, |
| 608 | SqlValidatorScope scope) { |
| 609 | SqlValidatorScope operandScope = scope; // REVIEW |
| 610 | |
| 611 | @SuppressWarnings("unused") |
| 612 | SqlIdentifier declName = this.declName; |
| 613 | SqlIdentifier refName = this.refName; |
| 614 | SqlNodeList partitionList = this.partitionList; |
| 615 | SqlNodeList orderList = this.orderList; |
| 616 | SqlLiteral isRows = this.isRows; |
| 617 | SqlNode lowerBound = this.lowerBound; |
| 618 | SqlNode upperBound = this.upperBound; |
| 619 | SqlLiteral allowPartial = this.allowPartial; |
| 620 | |
| 621 | if (refName != null) { |
| 622 | SqlWindow win = validator.resolveWindow(this, operandScope); |
| 623 | partitionList = win.partitionList; |
| 624 | orderList = win.orderList; |
| 625 | isRows = win.isRows; |
| 626 | lowerBound = win.lowerBound; |
| 627 | upperBound = win.upperBound; |
| 628 | allowPartial = win.allowPartial; |
| 629 | } |
| 630 | |
| 631 | for (SqlNode partitionItem : partitionList) { |
| 632 | try { |
| 633 | partitionItem.accept(Util.OverFinder.INSTANCE); |
| 634 | } catch (ControlFlowException e) { |
| 635 | throw validator.newValidationError(this, |
| 636 | RESOURCE.partitionbyShouldNotContainOver()); |
| 637 | } |
| 638 | |
| 639 | partitionItem.validateExpr(validator, operandScope); |
| 640 | } |
| 641 | |
| 642 | for (SqlNode orderItem : orderList) { |
| 643 | boolean savedColumnReferenceExpansion = |
| 644 | validator.config().columnReferenceExpansion(); |
| 645 | validator.transform(config -> config.withColumnReferenceExpansion(false)); |
| 646 | try { |
| 647 | orderItem.accept(Util.OverFinder.INSTANCE); |
| 648 | } catch (ControlFlowException e) { |
| 649 | throw validator.newValidationError(this, |
| 650 | RESOURCE.orderbyShouldNotContainOver()); |
| 651 | } |
| 652 | |
| 653 | try { |
| 654 | orderItem.validateExpr(validator, scope); |
| 655 | } finally { |
| 656 | validator.transform(config -> |
| 657 | config.withColumnReferenceExpansion(savedColumnReferenceExpansion)); |
| 658 | } |
| 659 | } |
| 660 | |
| 661 | // 6.10 rule 6a Function RANK & DENSE_RANK require ORDER BY clause |
| 662 | if (orderList.isEmpty() |
| 663 | && !SqlValidatorUtil.containsMonotonic(scope) |
| 664 | && windowCall != null |
no test coverage detected