Exploratory work on custom aggregate methods#1531
Closed
roji wants to merge 1 commit intonpgsql:mainfrom
Closed
Conversation
roji
commented
Oct 11, 2020
| return AggregateResultShaper(source, projection, throwWhenEmpty: true, typeof(string)); | ||
| } | ||
|
|
||
| #region Copied from RelationalQueryableMethodTranslatingExpressionVisitor |
Member
Author
There was a problem hiding this comment.
Note code copied below, which seems like it would be necessary for anyone needing to add top-level aggregate function support. Ideally this duplication wouldn't be necessary.
roji
commented
Oct 11, 2020
| @"@__p_1='|' | ||
| @__p_0='2' | ||
|
|
||
| SELECT string_agg(t.""ContactName"", @__p_1) |
roji
commented
Oct 11, 2020
| var lambdaBody = ReplacingExpressionVisitor.Replace( | ||
| lambdaExpression.Parameters.Single(), shapedQueryExpression.ShaperExpression, lambdaExpression.Body); | ||
|
|
||
| // TODO: Can't duplicate WeakEntityExpandingExpressionVisitor (ColumnExpression ctors are internal) |
Member
Author
There was a problem hiding this comment.
Apparently not possible support weak entities
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Following discussion in dotnet/efcore#13278, I attempted to translate string_agg, which is a PostgreSQL-specific aggregate function that reduces a set of values to a single string (concatenation). There are some other similar functions.
I did successfully managed to translate top-level (IQueryable) invocations, which is really cool. However, the current query pipeline doesn't seem to allow custom functions in the GroupBy aggregate case (e.g. GroupingElementExpression is private). Assuming we want to fully support arbitrary aggregate functions, we can use this to understand what's needed.
/cc @smitpatel @ajcvickers