private SortItem parseOrderByAttributeClause(
      IoTDBSqlParser.OrderByAttributeClauseContext ctx, ImmutableSet<String> limitSet) {
    if (ctx.sortKey() != null) {
      String sortKey = ctx.sortKey().getText().toUpperCase();
      if (!limitSet.contains(sortKey)) {
        throw new SemanticException(
            String.format("ORDER BY: sort key[%s] is not contained in '%s'", sortKey, limitSet));
      }
      return new SortItem(sortKey, ctx.DESC() != null ? Ordering.DESC : Ordering.ASC);
    } else {
      Expression sortExpression = parseExpression(ctx.expression(), true);
      return new SortItem(
          sortExpression,
          ctx.DESC() != null ? Ordering.DESC : Ordering.ASC,
          ctx.FIRST() != null ? NullOrdering.FIRST : NullOrdering.LAST);
    }
  }
Parse time range (startTime and endTime) in group by time.

@throws SemanticException if startTime is larger or equals to endTime in timeRange
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java