Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkMpn committed Dec 30, 2021
1 parent 4a50ec9 commit f411029
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
34 changes: 21 additions & 13 deletions MarkMpn.Sql4Cds.Engine.Tests/ExecutionPlanTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -481,12 +481,13 @@ public void SimpleGroupAggregate()
<order alias='name' />
</entity>
</fetch>");
var aggregate = AssertNode<HashMatchAggregateNode>(tryCatch1.CatchSource);
var aggregate = AssertNode<StreamAggregateNode>(tryCatch1.CatchSource);
var scalarFetch = AssertNode<FetchXmlScan>(aggregate.Source);
AssertFetchXml(scalarFetch, @"
<fetch>
<entity name='account'>
<attribute name='name' />
<order attribute='name' />
</entity>
</fetch>");
}
Expand Down Expand Up @@ -531,12 +532,13 @@ public void AliasedAggregate()
<order alias='name' />
</entity>
</fetch>");
var aggregate = AssertNode<HashMatchAggregateNode>(tryCatch1.CatchSource);
var aggregate = AssertNode<StreamAggregateNode>(tryCatch1.CatchSource);
var scalarFetch = AssertNode<FetchXmlScan>(aggregate.Source);
AssertFetchXml(scalarFetch, @"
<fetch>
<entity name='account'>
<attribute name='name' />
<order attribute='name' />
</entity>
</fetch>");
}
Expand Down Expand Up @@ -581,12 +583,13 @@ public void AliasedGroupingAggregate()
<order alias='name' />
</entity>
</fetch>");
var aggregate = AssertNode<HashMatchAggregateNode>(tryCatch1.CatchSource);
var aggregate = AssertNode<StreamAggregateNode>(tryCatch1.CatchSource);
var scalarFetch = AssertNode<FetchXmlScan>(aggregate.Source);
AssertFetchXml(scalarFetch, @"
<fetch>
<entity name='account'>
<attribute name='name' />
<order attribute='name' />
</entity>
</fetch>");
}
Expand Down Expand Up @@ -668,14 +671,15 @@ GROUP BY name
<order alias='name' />
</entity>
</fetch>");
var aggregate = AssertNode<HashMatchAggregateNode>(tryCatch1.CatchSource);
var aggregate = AssertNode<StreamAggregateNode>(tryCatch1.CatchSource);
Assert.AreEqual("account.name", aggregate.GroupBy[0].ToSql());
Assert.AreEqual("count", aggregate.Aggregates.Single().Key);
var scalarFetch = AssertNode<FetchXmlScan>(aggregate.Source);
AssertFetchXml(scalarFetch, @"
<fetch>
<entity name='account'>
<attribute name='name' />
<order attribute='name' />
</entity>
</fetch>");
}
Expand Down Expand Up @@ -999,7 +1003,7 @@ public void SelectSubqueryWithNestedLoop()
</entity>
</fetch>");
var subAssert = AssertNode<AssertNode>(nestedLoop.RightSource);
var subAggregate = AssertNode<HashMatchAggregateNode>(subAssert.Source);
var subAggregate = AssertNode<StreamAggregateNode>(subAssert.Source);
var subIndexSpool = AssertNode<IndexSpoolNode>(subAggregate.Source);
Assert.AreEqual("account.createdon", subIndexSpool.KeyColumn);
Assert.AreEqual("@Expr2", subIndexSpool.SeekValue);
Expand Down Expand Up @@ -1049,7 +1053,7 @@ public void SelectSubqueryWithSmallNestedLoop()
</entity>
</fetch>");
var subAssert = AssertNode<AssertNode>(nestedLoop.RightSource);
var subAggregate = AssertNode<HashMatchAggregateNode>(subAssert.Source);
var subAggregate = AssertNode<StreamAggregateNode>(subAssert.Source);
var subAggregateFetch = AssertNode<FetchXmlScan>(subAggregate.Source);
AssertFetchXml(subAggregateFetch, @"
<fetch>
Expand Down Expand Up @@ -1139,7 +1143,7 @@ public void SelectSubqueryWithCorrelatedSpooledNestedLoop()
</entity>
</fetch>");
var subAssert = AssertNode<AssertNode>(nestedLoop.RightSource);
var subAggregate = AssertNode<HashMatchAggregateNode>(subAssert.Source);
var subAggregate = AssertNode<StreamAggregateNode>(subAssert.Source);
var subIndexSpool = AssertNode<IndexSpoolNode>(subAggregate.Source);
Assert.AreEqual("account.createdon", subIndexSpool.KeyColumn);
Assert.AreEqual("@Expr2", subIndexSpool.SeekValue);
Expand Down Expand Up @@ -1190,7 +1194,7 @@ public void SelectSubqueryWithPartiallyCorrelatedSpooledNestedLoop()
</entity>
</fetch>");
var subAssert = AssertNode<AssertNode>(nestedLoop.RightSource);
var subAggregate = AssertNode<HashMatchAggregateNode>(subAssert.Source);
var subAggregate = AssertNode<StreamAggregateNode>(subAssert.Source);
var subIndexSpool = AssertNode<IndexSpoolNode>(subAggregate.Source);
Assert.AreEqual("account.createdon", subIndexSpool.KeyColumn);
Assert.AreEqual("@Expr2", subIndexSpool.SeekValue);
Expand Down Expand Up @@ -1245,7 +1249,7 @@ public void SelectSubqueryUsingOuterReferenceInSelectClause()
</entity>
</fetch>");
var subAssert = AssertNode<AssertNode>(nestedLoop.RightSource);
var subAggregate = AssertNode<HashMatchAggregateNode>(subAssert.Source);
var subAggregate = AssertNode<StreamAggregateNode>(subAssert.Source);
var subCompute = AssertNode<ComputeScalarNode>(subAggregate.Source);
var subIndexSpool = AssertNode<IndexSpoolNode>(subCompute.Source);
Assert.AreEqual("account.accountid", subIndexSpool.KeyColumn);
Expand Down Expand Up @@ -2312,12 +2316,13 @@ public void AggregateSort()
var sort = AssertNode<SortNode>(tryCatch1.CatchSource);
Assert.AreEqual("count", sort.Sorts.Single().Expression.ToSql());
Assert.AreEqual(SortOrder.Descending, sort.Sorts.Single().SortOrder);
var aggregate = AssertNode<HashMatchAggregateNode>(sort.Source);
var aggregate = AssertNode<StreamAggregateNode>(sort.Source);
var fetch = AssertNode<FetchXmlScan>(aggregate.Source);
AssertFetchXml(fetch, @"
<fetch>
<entity name='account'>
<attribute name='name' />
<order attribute='name' />
</entity>
</fetch>");
}
Expand Down Expand Up @@ -2806,14 +2811,15 @@ public void MinAggregateNotFoldedToFetchXmlForOptionset()
Assert.AreEqual(1, plans.Length);

var select = AssertNode<SelectNode>(plans[0]);
var aggregate = AssertNode<HashMatchAggregateNode>(select.Source);
var aggregate = AssertNode<StreamAggregateNode>(select.Source);
var fetchXml = AssertNode<FetchXmlScan>(aggregate.Source);

AssertFetchXml(fetchXml, @"
<fetch>
<entity name='new_customentity'>
<attribute name='new_name' />
<attribute name='new_optionsetvalue' />
<order attribute='new_name' />
</entity>
</fetch>");
}
Expand Down Expand Up @@ -2904,7 +2910,7 @@ GROUP BY firstname
</entity>
</fetch>");

var innerAggregate = AssertNode<HashMatchAggregateNode>(innerTry1.CatchSource);
var innerAggregate = AssertNode<StreamAggregateNode>(innerTry1.CatchSource);
Assert.AreEqual("contact.firstname", innerAggregate.GroupBy[0].GetColumnName());
Assert.AreEqual("count", innerAggregate.Aggregates.First().Key);
Assert.AreEqual(AggregateType.CountStar, innerAggregate.Aggregates.First().Value.AggregateType);
Expand All @@ -2914,6 +2920,7 @@ GROUP BY firstname
<fetch>
<entity name='contact'>
<attribute name='firstname' />
<order attribute='firstname' />
</entity>
</fetch>");

Expand Down Expand Up @@ -2999,12 +3006,13 @@ public void GroupByDatetimeWithoutDatePart()
Assert.AreEqual(1, plans.Length);

var select = AssertNode<SelectNode>(plans[0]);
var aggregate = AssertNode<HashMatchAggregateNode>(select.Source);
var aggregate = AssertNode<StreamAggregateNode>(select.Source);
var fetch = AssertNode<FetchXmlScan>(aggregate.Source);
AssertFetchXml(fetch, @"
<fetch>
<entity name='account'>
<attribute name='createdon' />
<order attribute='createdon' />
</entity>
</fetch>");
}
Expand Down
3 changes: 3 additions & 0 deletions MarkMpn.Sql4Cds.Engine.Tests/Sql2FetchXmlTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,7 @@ public void CustomFilterAggregateHavingProjectionSortAndTop()
<attribute name='lastname' />
<attribute name='firstname' />
<attribute name='createdon' />
<order attribute='lastname' />
</entity>
</fetch>
");
Expand Down Expand Up @@ -1465,6 +1466,7 @@ public void GroupCaseInsensitive()
<entity name='contact'>
<attribute name='lastname' />
<attribute name='createdon' />
<order attribute='lastname' />
</entity>
</fetch>
");
Expand Down Expand Up @@ -1574,6 +1576,7 @@ public void AggregateQueryProducesAlternative()
<fetch>
<entity name='account'>
<attribute name='name' />
<order attribute='name' />
</entity>
</fetch>
");
Expand Down

0 comments on commit f411029

Please sign in to comment.