protected void validateOrderList(SqlSelect select) {
		// ORDER BY is validated in a scope where aliases in the SELECT clause
		// are visible. For example, "SELECT empno AS x FROM emp ORDER BY x"
		// is valid.
		SqlNodeList orderList = select.getOrderList();
		if (orderList == null) {
			return;
		}
		if (!shouldAllowIntermediateOrderBy()) {
			if (!cursorSet.contains(select)) {
				throw newValidationError(select, RESOURCE.invalidOrderByPos());
			}
		}
		final SqlValidatorScope orderScope = getOrderScope(select);
		Objects.requireNonNull(orderScope);

		List<SqlNode> expandList = new ArrayList<>();
		for (SqlNode orderItem : orderList) {
			SqlNode expandedOrderItem = expand(orderItem, orderScope);
			expandList.add(expandedOrderItem);
		}

		SqlNodeList expandedOrderList = new SqlNodeList(
			expandList,
			orderList.getParserPosition());
		select.setOrderBy(expandedOrderList);

		for (SqlNode orderItem : expandedOrderList) {
			validateOrderItem(select, orderItem);
		}
	}
protected void validateOrderList ( SqlSelect select ) { SqlNodeList orderList = select . getOrderList ( ) ; if ( orderList == null ) { return ; } if ( ! shouldAllowIntermediateOrderBy ( ) ) { if ( ! cursorSet . contains ( select ) ) { throw newValidationError ( select , RESOURCE . invalidOrderByPos ( ) ) ; } } final SqlValidatorScope orderScope = getOrderScope ( select ) ; Objects . requireNonNull ( orderScope ) ; List < SqlNode > expandList = new ArrayList < > ( ) ; for ( SqlNode orderItem : orderList ) { SqlNode expandedOrderItem = expand ( orderItem , orderScope ) ; expandList . add ( expandedOrderItem ) ; } SqlNodeList expandedOrderList = new SqlNodeList ( expandList , orderList . getParserPosition ( ) ) ; select . setOrderBy ( expandedOrderList ) ; for ( SqlNode orderItem : expandedOrderList ) { validateOrderItem ( select , orderItem ) ; } }
Validates the ORDER BY clause of a SELECT statement.

@param select Select statement