MCPcopy Create free account
hub / github.com/apache/calcite / validate

Method validate

core/src/main/java/org/apache/calcite/sql/SqlWindow.java:607–732  ·  view source on GitHub ↗
(SqlValidator validator,
      SqlValidatorScope scope)

Source from the content-addressed store, hash-verified

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

Callers 1

validateWindowMethod · 0.95

Calls 15

isEmptyMethod · 0.95
containsMonotonicMethod · 0.95
sizeMethod · 0.95
isRowsMethod · 0.95
onlySymbolBoundsMethod · 0.95
getMethod · 0.95
getSqlTypeNameMethod · 0.95
validateFrameBoundaryMethod · 0.95
checkSpecialLiteralsMethod · 0.95
isAllowPartialMethod · 0.95

Tested by

no test coverage detected