Cosmos: bad exception for queries with aggregate selecting non-mapped type
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
Research direction
Start with SelectExpression.GetMappedProjection and CosmosQueryableMethodTranslatingExpressionVisitor.TranslateAverage, using the failing query and stack trace as the entry point. Review NorthwindAggregateOperatorsQueryTestBase.Average_with_unmapped_property_access_throws_meaningful_exception. Done means the unmapped aggregate query reports a meaningful exception instead of KeyNotFoundException.
Written by the indexing model from the issue text.
Description
query:
ctx.Orders.Average(o => o.ShipVia)
exception:
System.Collections.Generic.KeyNotFoundException : The given key 'EmptyProjectionMember' was not present in the dictionary.
Stack Trace:
Dictionary`2.get_Item(TKey key)
SelectExpression.GetMappedProjection(ProjectionMember projectionMember) line 131
CosmosQueryableMethodTranslatingExpressionVisitor.TranslateAverage(ShapedQueryExpression source, LambdaExpression selector, Type resultType) line 193
QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression) line 119
MethodCallExpression.Accept(ExpressionVisitor visitor)
ExpressionVisitor.Visit(Expression node)
QueryCompilationContext.CreateQueryExecutor[TResult](Expression query) line 91
Database.CompileQuery[TResult](Expression query, Boolean async) line 71
QueryCompiler.CompileQueryCore[TResult](IDatabase database, Expression query, IModel model, Boolean async) line 112
<>c__DisplayClass9_0`1.<Execute>b__0() line 96
CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func`1 compiler) line 76
CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler) line 51
QueryCompiler.Execute[TResult](Expression query) line 92
EntityQueryProvider.Execute[TResult](Expression expression) line 79
Queryable.Average[TSource](IQueryable`1 source, Expression`1 selector)
QueryAsserter`1.AssertAverage[TResult](Func`2 actualQuery, Func`2 expectedQuery, Expression`1 actualSelector, Expression`1 expectedSelector, Action`2 asserter, Boolean async) line 1305
NorthwindAggregateOperatorsQueryTestBase`1.Average_with_unmapped_property_access_throws_meaningful_exception(Boolean async) line 1896
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 134
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dotnet/efcore
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
-
customer-reported
Difficulty 5/5 Over a week Newbie friendliness 38/100
-
area-cosmos area-vector-search
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
area-cosmos
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
area-tools needs-design
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SubtitleEdit/subtitleedit#15108 · 1 comment ·
-
area/docs-content Bug pulumi/docs
Difficulty 1/5 1-3 hours Newbie friendliness 94/100
-
agentic-workflows untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 76/100