public SelectionOperator(LogicalOperator inOp, IList <SortItem> orderExprs, LimitClause limit)
 {
     FilterExpression = null;
     UnexpandedEntityInequalityConditions = null;
     SetInOperator(inOp);
     OrderByExpressions = orderExprs;
     Limit = limit;
 }
Beispiel #2
0
        public void LimitClause(string expected, int size, int offset)
        {
            var clause = new LimitClause(size, offset);

            var sql = clause.ToString();

            Output.WriteLine(sql);
            sql.ShouldBeEquivalentTo(expected);
        }
Beispiel #3
0
 public SingleSeriesSelectStatement(
     SelectClause select,
     FromClause from,
     WhereClause where     = null,
     GroupByClause groupBy = null,
     FillClause fill       = null,
     OrderByClause orderBy = null,
     LimitClause limit     = null,
     OffsetClause offset   = null
     )
 {
     Select  = select ?? throw new ArgumentNullException(nameof(select));
     From    = from ?? throw new ArgumentNullException(nameof(from));
     Where   = where;
     GroupBy = groupBy;
     Fill    = fill;
     OrderBy = orderBy;
     Limit   = limit;
     Offset  = offset;
 }
Beispiel #4
0
        public DistributorPlan Plan(Query input)
        {
            SelectClause         underlyingSelect = null;
            Option <LimitClause> underlyingLimit  = new None();

            Option <OrderClause> order = new None();
            Option <LimitClause> limit = new None();

            if (input.Order.IsSome)
            {
                var builder = new PlanOrderBuilder(input, input.Order.AsT0);

                underlyingSelect = builder.UnderlyingSelect;
                order            = builder.Order;
            }

            if (input.Limit.IsSome)
            {
                var limitValue = input.Limit.AsT0;

                limit = limitValue;

                // we can't sort on the underlying query so we need to load the whole result set
                if (input.Order.IsNone)
                {
                    underlyingLimit = new LimitClause(limitValue.Limit);
                }
            }

            if (underlyingSelect == null)
            {
                underlyingSelect = input.Select;
            }

            var underlying = new Query(underlyingSelect, input.From, input.Where, new None(), underlyingLimit);

            return(new DistributorPlan(input, underlying, order, limit));
        }
Beispiel #5
0
 public SqlQuery Limit(int rows, bool percent = false)
 {
     _limitClause = new LimitClause(rows, percent);
     return(this);
 }
 public static string CompileLimit(this LimitClause limit)
 {
     return(limit != null ? $"TOP {limit.LimitCommand}" : "");
 }
Beispiel #7
0
 public static void AssertEqual(LimitClause expected, LimitClause actual)
 {
     Assert.Equal(expected.Limit, actual.Limit);
 }