private static ShowPlanNode BuildConstant(BoundConstantRelation node) { var properties = Enumerable.Empty <KeyValuePair <string, string> >(); var children = Enumerable.Empty <ShowPlanNode>(); return(new ShowPlanNode(@"Constant", properties, children)); }
private static BoundRelation RewriteDisjunctions(BoundExpression condition) { var scalarPredicates = new List <BoundExpression>(); var relationalPredicates = new List <BoundRelation>(); foreach (var disjunction in Expression.SplitDisjunctions(condition)) { BoundExistsSubselect exists; bool isNegated; if (TryGetExistsSubselect(disjunction, out exists, out isNegated)) { if (!isNegated) { relationalPredicates.Add(exists.Relation); } else { var constantRelation = new BoundConstantRelation(); var predicate = new BoundJoinRelation(BoundJoinType.LeftAntiSemi, constantRelation, exists.Relation, null, null, null); relationalPredicates.Add(predicate); } } else if (Expression.IsConjunction(disjunction)) { var constantRelation = new BoundConstantRelation(); var output = RewriteConjunctions(constantRelation, disjunction); if (output == null) { scalarPredicates.Add(disjunction); } else { var predicate = new BoundJoinRelation(BoundJoinType.LeftSemi, constantRelation, output, null, null, null); relationalPredicates.Add(predicate); } } else { scalarPredicates.Add(disjunction); } } if (relationalPredicates.Count == 0) { return(null); } if (scalarPredicates.Count > 0) { var constantRelation = new BoundConstantRelation(); var predicate = Expression.Or(scalarPredicates); var filter = new BoundFilterRelation(constantRelation, predicate); relationalPredicates.Insert(0, filter); } return(new BoundConcatenationRelation(relationalPredicates, Enumerable.Empty <BoundUnifiedValue>())); }
private static BoundQuery CreateBoundQuery(BoundExpression expression) { var factory = new ValueSlotFactory(); var valueSlot = new ValueSlot(factory, @"result", 0, expression.Type); var computedValue = new BoundComputedValue(expression, valueSlot); var constantRelation = new BoundConstantRelation(); var computeRelation = new BoundComputeRelation(constantRelation, new[] { computedValue }); var projectRelation = new BoundProjectRelation(computeRelation, new [] { valueSlot }); var columnSymbol = new QueryColumnInstanceSymbol(valueSlot.Name, valueSlot); return(new BoundQuery(projectRelation, new[] { columnSymbol })); }
private static CardinalityEstimate EstimateConstantRelation(BoundConstantRelation relation) { return(CardinalityEstimate.SingleRow); }