protected override void VisitGroupByOp(GroupByBaseOp op, System.Data.Entity.Core.Query.InternalTrees.Node n) { foreach (Var key in op.Keys) { if (TypeUtils.IsStructuredType(key.Type)) { this.AddPropertyRefs(key, PropertyRefList.All); } } this.VisitChildrenReverse(n); }
/// <summary> /// GroupByOp handling /// </summary> /// <param name="op"></param> /// <param name="n"></param> protected override void VisitGroupByOp(GroupByBaseOp op, Node n) { // First "request" all properties for every key (that is a structured type) foreach (Var v in op.Keys) { if (TypeUtils.IsStructuredType(v.Type)) { AddPropertyRefs(v, PropertyRefList.All); } } // Now visit the aggregate definitions, the key definitions, and // the relop input in that order VisitChildrenReverse(n); }
/// <summary> /// GroupByBase /// First, we visit the vardeflist for aggregates and potentially group aggregates /// as they may reference keys (including constant keys). /// Then we remove all null and constant keys that are not referenced as long as /// there is one key left. We add all remaining key columns to the referenced list. /// Then we walk through the vardeflist for the keys; and finally process the relop input /// Once we're done, we update the "Outputs" varset - to account for any /// pruned vars. The "Keys" varset will not change /// </summary> /// <param name="op"> the groupbyOp </param> /// <param name="n"> current subtree </param> /// <returns> modified subtree </returns> protected override Node VisitGroupByOp(GroupByBaseOp op, Node n) { // DevDiv#322980: Visit the vardeflist for aggregates and potentially group aggregates before removing // redundant constant keys. This is because they may depend on (reference) the keys for (var i = n.Children.Count - 1; i >= 2; i--) { n.Children[i] = VisitNode(n.Children[i]); } //All constant and null keys that are not referenced can be removed //as long as there is at least one key left. if (op.Keys.Count > 1) { RemoveRedundantConstantKeys(op.Keys, op.Outputs, n.Child1); } AddReference(op.Keys); // all keys are referenced //Visit the keys n.Children[1] = VisitNode(n.Children[1]); //Visit the input n.Children[0] = VisitNode(n.Children[0]); PruneVarSet(op.Outputs); // remove unnecessary vars from the outputs //SQLBUDT #543064: If there are no keys to start with // and none of the aggregates is referenced, the GroupBy // is equivalent to a SingleRowTableOp if (op.Keys.Count == 0 && op.Outputs.Count == 0) { return(m_command.CreateNode(m_command.CreateSingleRowTableOp())); } m_command.RecomputeNodeInfo(n); return(n); }
protected override System.Data.Entity.Core.Query.InternalTrees.Node VisitGroupByOp( GroupByBaseOp op, System.Data.Entity.Core.Query.InternalTrees.Node n) { for (int index = n.Children.Count - 1; index >= 2; --index) { n.Children[index] = this.VisitNode(n.Children[index]); } if (op.Keys.Count > 1) { this.RemoveRedundantConstantKeys(op.Keys, op.Outputs, n.Child1); } this.AddReference((IEnumerable <Var>)op.Keys); n.Children[1] = this.VisitNode(n.Children[1]); n.Children[0] = this.VisitNode(n.Children[0]); this.PruneVarSet(op.Outputs); if (op.Keys.Count == 0 && op.Outputs.Count == 0) { return(this.m_command.CreateNode((Op)this.m_command.CreateSingleRowTableOp())); } this.m_command.RecomputeNodeInfo(n); return(n); }
protected override void VisitGroupByOp(GroupByBaseOp op, Node n) { VisitRelOpDefault(op, n); AssertRelOpOrPhysicalOp(n.Child0.Op); for (var i = 1; i < n.Children.Count; i++) { AssertOpType(n.Children[i].Op, OpType.VarDefList); } }
/// <summary> /// Default handler for all GroupBy ops /// </summary> /// <param name="op"> sort op </param> /// <param name="n"> </param> protected virtual void VisitGroupByOp(GroupByBaseOp op, Node n) { VisitRelOpDefault(op, n); }
/// <summary> /// GroupByOp handling /// </summary> /// <param name="op"> </param> /// <param name="n"> </param> protected override void VisitGroupByOp(GroupByBaseOp op, Node n) { // First "request" all properties for every key (that is a structured type) foreach (var v in op.Keys) { if (TypeUtils.IsStructuredType(v.Type)) { AddPropertyRefs(v, PropertyRefList.All); } } // Now visit the aggregate definitions, the key definitions, and // the relop input in that order VisitChildrenReverse(n); }
protected override void VisitGroupByOp(GroupByBaseOp op, Node n) { VisitRelOpDefault(op, n); Map(op.Outputs); Map(op.Keys); }
protected override void VisitGroupByOp(GroupByBaseOp op, System.Data.Entity.Core.Query.InternalTrees.Node n) { this.VisitRelOpDefault((RelOp)op, n); this.Map(op.Outputs); this.Map(op.Keys); }