Gets the select expression order.

@param query
the query
@return the select expression order
555249
public ListIterable<Expression> getSelectExpressionOrder(KunderaQuery query)
    {
        if (!KunderaQueryUtils.isSelectStatement(query.getJpqlExpression()))
        {
            return null;
        }
        Expression selectExpression = ((SelectClause) (query.getSelectStatement()).getSelectClause())
                .getSelectExpression();

        List<Expression> list;

        if (!(selectExpression instanceof CollectionExpression))
        {
            list = new LinkedList<Expression>();
            list.add(selectExpression);
            return new SnapshotCloneListIterable<Expression>(list);
        }
        else
        {
            return selectExpression.children();
        }
    }
227380
@NonNull
    public Expression match(@NonNull String query) {
        if (query == null) {
            throw new IllegalArgumentException("query is null.");
        }
        return new FullTextMatchExpression(this.name, query);
    }
348979
public function order($query)
    {
        $clause = '';

        if (!empty($query->order)) {
            $clause = 'ORDER BY ';
            $list = array();
            foreach ($query->order as $order) {
                $columns = AnDomainQueryHelper::parseColumns($query, $order['column']);
                foreach ($columns as $column) {
                    $list[] = $column.' '.$order['direction'];
                }
            }

            $clause .= implode(' , ', $list);
        }

        return $clause;
    }
301271
public static void applyOrderBy(MultivaluedMap<String, String> queryParams, Query query) {
        List<String> orders = queryParams.get(SORT_PARAM_NAME);
        if (orders != null && orders.size() > 0) {
            OrderBy orderBy = query.orderBy();
            for (String order : orders) {
                EbeanUtils.appendOrder(orderBy, order);
            }
        }
    }
1092369
@NonNull
    public static SortOrder expression(@NonNull Expression expression) {
        if (expression == null) {
            throw new IllegalArgumentException("expression cannot be null.");
        }
        return new SortOrder(expression);
    }
17359
public void search(String query) {
        final Query newQuery = searcher.getQuery().setQuery(query);
        searcher.setQuery(newQuery).search();
    }
889433
private String getSQLCondition(Function atom, AliasIndex index) {
		Predicate functionSymbol = atom.getFunctionSymbol();
		if (operations.containsKey(functionSymbol)) {
			String expressionFormat = operations.get(functionSymbol);
			if (functionSymbol.getArity() == 1) {
				// For unary boolean operators, e.g., NOT, IS NULL, IS NOT NULL.
				Term term = atom.getTerm(0);
				final String arg;
				if (functionSymbol == ExpressionOperation.NOT) {
					arg = (term instanceof Function && ((Function) term).isDataTypeFunction())
							? effectiveBooleanValue(term, index)
							: getSQLString(term, index, false);
				}
				else {
					arg = getSQLString(term, index, false);
				}
				return String.format(expressionFormat, arg);
			}
			else if (functionSymbol.getArity() == 2) {
				// For binary boolean operators, e.g., AND, OR, EQ, GT, LT, etc.
				String left = getSQLString(atom.getTerm(0), index, true);
				String right = getSQLString(atom.getTerm(1), index, true);
				return String.format(inBrackets(expressionFormat), left, right);
			}
		}
		else if (functionSymbol == ExpressionOperation.IS_TRUE) {
			return effectiveBooleanValue(atom.getTerm(0), index);
		}
		else if (functionSymbol == ExpressionOperation.REGEX) {
			boolean caseinSensitive = false, multiLine = false, dotAllMode = false;
			if (atom.getArity() == 3) {
				String options = atom.getTerm(2).toString();
				caseinSensitive = options.contains("i");
				multiLine = options.contains("m");
				dotAllMode = options.contains("s");
			}
			String column = getSQLString(atom.getTerm(0), index, false);
			String pattern = getSQLString(atom.getTerm(1), index, false);
			return sqladapter.sqlRegex(column, pattern, caseinSensitive, multiLine, dotAllMode);
		}

		throw new RuntimeException("The builtin function " + functionSymbol + " is not supported yet!");
	}
643927
protected function checkOrder(Sql\Select $query)
    {
        $order  = $this->getEntityDescriptor()->getPrimaryKey()->getField();
        $order .= " DESC";
        if (null != $this->order) {
            $order = $this->order;
        }
        $query->order($order);
        return $this;
    }
85444
protected IndexQuery generateIndexQuery(String query) {
        IndexQuery indexQuery = new IndexQuery();
        indexQuery.setQuery(query);
        indexQuery.setStart(start);
        indexQuery.setWaitForNonStaleResults(theWaitForNonStaleResults);
        indexQuery.setWaitForNonStaleResultsTimeout(timeout);
        indexQuery.setQueryParameters(queryParameters);
        indexQuery.setDisableCaching(disableCaching);

        if (pageSize != null) {
            indexQuery.setPageSize(pageSize);
        }
        return indexQuery;
    }
230468
public R textQueryString(String query, TextQueryString options) {
    peekExprList().textQueryString(query, options);
    return root;
  }
641282
public String query(String query) {
        try {
            Connection conn = this.tx().getConnection();
            ObjectNode result = this.mapper.createObjectNode();
            ArrayNode dataNode = this.mapper.createArrayNode();
            ArrayNode metaNode = this.mapper.createArrayNode();
            Statement statement = conn.createStatement();
            if (logger.isDebugEnabled()) {
                logger.debug(query);
            }
            ResultSet rs = statement.executeQuery(query);
            ResultSetMetaData rsmd = rs.getMetaData();
            boolean first = true;
            while (rs.next()) {
                int numColumns = rsmd.getColumnCount();
                ObjectNode obj = this.mapper.createObjectNode();
                for (int i = 1; i < numColumns + 1; i++) {
                    String columnName = rsmd.getColumnLabel(i);
                    int type = rsmd.getColumnType(i);
                    //make sure to obtain array using getArray()
                    //At least in H2, this makes a difference...
                    Object o = type == Types.ARRAY ? rs.getArray(i) : rs.getObject(i);
                    this.sqlDialect.putJsonObject(obj, columnName, type, o);
                    if (first) {
                        this.sqlDialect.putJsonMetaObject(this.mapper, metaNode, columnName, type, o);
                    }
                }
                first = false;
                dataNode.add(obj);
            }
            result.set("data", dataNode);
            result.set("meta", metaNode);
            return result.toString();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            this.tx().rollback();
        }
    }
554260
private void parseInputQuery(String query) {
    List<String> projectedColumns = new ArrayList<>();
    if (StringUtils.isNotBlank(query)) {
      String queryLowerCase = query.toLowerCase();
      int startIndex = queryLowerCase.indexOf("select ") + 7;
      int endIndex = queryLowerCase.indexOf(" from ");
      if (startIndex >= 0 && endIndex >= 0) {
        String columnProjection = query.substring(startIndex, endIndex);
        this.setInputColumnProjection(columnProjection);
        // parse the select list
        StringBuffer sb = new StringBuffer();
        int bracketCount = 0;
        for (int i = 0; i < columnProjection.length(); i++) {
          char c = columnProjection.charAt(i);
          if (c == '(') {
            bracketCount++;
          }

          if (c == ')') {
            bracketCount--;
          }

          if (bracketCount != 0) {
            sb.append(c);
          } else {
            if (c != ',') {
              sb.append(c);
            } else {
              projectedColumns.add(sb.toString());
              sb = new StringBuffer();
            }
          }
        }
        projectedColumns.add(sb.toString());
      }
    }

    if (this.isSelectAllColumns()) {
      List<String> columnList = this.getMetadataColumnList();
      for (String columnName : columnList) {
        ColumnAttributes col = new ColumnAttributes();
        col.setColumnName(columnName);
        col.setAliasName(columnName);
        col.setSourceColumnName(columnName);
        this.addToColumnAliasMap(col);
      }
    } else {
      for (String projectedColumn : projectedColumns) {
        String column = projectedColumn.trim();
        String alias = null;
        String sourceColumn = column;
        int spaceOccurences = StringUtils.countMatches(column.trim(), " ");
        if (spaceOccurences > 0) {
          // separate column and alias if they are separated by "as"
          // or space
          int lastSpaceIndex = column.toLowerCase().lastIndexOf(" as ");
          sourceColumn = column.substring(0, lastSpaceIndex);
          alias = column.substring(lastSpaceIndex + 4);
        }

        // extract column name if projection has table name in it
        String columnName = sourceColumn;
        if (sourceColumn.contains(".")) {
          columnName = sourceColumn.substring(sourceColumn.indexOf(".") + 1);
        }

        ColumnAttributes col = new ColumnAttributes();
        col.setColumnName(columnName);
        col.setAliasName(alias);
        col.setSourceColumnName(sourceColumn);
        this.addToColumnAliasMap(col);
      }
    }
  }
605103
public int getSortIndexOfOrderByExpression(AbstractExpression partitionByExpression) {
        for (int idx = 0; idx < m_orderByExpressions.size(); ++idx) {
            if (m_orderByExpressions.get(idx).equals(partitionByExpression)) {
                return idx;
            }
        }
        return -1;
    }
122004
public PaginatedResult execute(final Query query) {
        final long count = getCount(query);
        decorate(query);
        return new PaginatedResult()
                .objects(query.execute())
                .total(count);
    }
348730
protected function parseOrder(Query $query, $order)
    {
        foreach ($order as $key => $val) {
            if ($val instanceof Expression) {
                $array[] = $val->getValue();
            } elseif (is_array($val) && preg_match('/^[\w\.]+$/', $key)) {
                $array[] = $this->parseOrderField($query, $key, $val);
            } elseif ('[rand]' == $val) {
                $array[] = $this->parseRand($query);
            } elseif (is_string($val)) {
                if (is_numeric($key)) {
                    list($key, $sort) = explode(' ', strpos($val, ' ') ? $val : $val . ' ');
                } else {
                    $sort = $val;
                }

                if (preg_match('/^[\w\.]+$/', $key)) {
                    $sort    = strtoupper($sort);
                    $sort    = in_array($sort, ['ASC', 'DESC'], true) ? ' ' . $sort : '';
                    $array[] = $this->parseKey($query, $key, true) . $sort;
                } else {
                    throw new Exception('order express error:' . $key);
                }
            }
        }

        return empty($array) ? '' : ' ORDER BY ' . implode(',', $array);
    }
1310047
public function buildOrderByFragment(SQLSelect $query, array &$parameters)
    {
        $orderBy = $query->getOrderBy();
        if (empty($orderBy)) {
            return '';
        }

        // Build orders, each with direction considered
        $statements = array();
        foreach ($orderBy as $clause => $dir) {
            $statements[] = trim("$clause $dir");
        }

        $nl = $this->getSeparator();
        return "{$nl}ORDER BY " . implode(', ', $statements);
    }
389345
public MapReduceOptions<T> query(final Query query) {
        Assert.parametersNotNull("query", query);
        this.query = query;
        return this;
    }