protected void ensureOrderSpec(WindowFunctionSpec wFn) throws SemanticException {
      if (getOrder() == null) {
        /*
         * In case of RANGE windows, an explicit ORDER BY clause is needed, otherwise the query ends
         * up in undefined behavior, considering the following:
         *
         * count(*) over(partition by partitioning_col range between 1 preceding and current row) as cs1
         *
         * The query above leads to undefined behavior, because it makes no sense to calculate range on:
         * 1. undefined column (obviously)
         * 2. the partitioning column, as the partitioning column means that all the rows
         *    have the same value within the partition (or NULL)
         */
        if (windowFrame.getWindowType() == WindowType.RANGE
            && (windowFrame.getStart().isBoundedNotCurrent()
                || windowFrame.getEnd().isBoundedNotCurrent())) {
          throw new SemanticException(
              "RANGE with offset PRECEDING/FOLLOWING requires at least one ORDER BY column");
        }
        OrderSpec order = new OrderSpec();
        order.prefixBy(getPartition());
        setOrder(order);
      }
    }
Add default order spec if there is no order and validate order spec for valued based
windowing since only one sort key is allowed.
@param wFn Window function spec
@throws SemanticException
ql/src/java/org/apache/hadoop/hive/ql/parse/WindowingSpec.java