-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sql: Add overloads to ARRAY_AGG #21377
Conversation
e77a27f
to
68a5d94
Compare
that was much simpler than I expected! Review status: 0 of 2 files reviewed at latest revision, 1 unresolved discussion, some commit checks pending. docs/generated/sql/aggregates.md, line 4 at r1 (raw file):
😢 this is so unfortunate @knz do you know offhand if we have any way of supporting very basic generic functions (not full HM but something that would handle the array situation)? Comments from Reviewable |
Review status: 0 of 2 files reviewed at latest revision, 1 unresolved discussion, some commit checks failed. docs/generated/sql/aggregates.md, line 4 at r1 (raw file): Previously, justinj (Justin Jaffray) wrote…
You mean to generate the documentation? Yes we could enhance the doc generator. If you mean avoid instantiating the overload explicitly, yes I suppose we can bake something ad-hoc but I am not happy at the thought. If we are to invest in typing we should figure out something principled first. Comments from Reviewable |
So when I tried to fix the failing tests, I encountered an ORM compatibility issue with sequelize. It seems as though it expects to receive a string and convert it to an array of strings, but after my change, it receives an array of strings and fails when it tries to call strings functions on it. I'm investigating this more closely now, but as a result of this, I can't merge this PR right now. |
0a1ba01
to
dbb5d07
Compare
I managed to work around the ORM compatibility issue by retaining most of the old |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but maybe add some extra tests for the aliased types, like NAME
to make sure they still work (and will continue to work).
} | ||
// Whenever possible, use the expression's type, so we can properly | ||
// handle aliased types that don't explicitly have overloads. | ||
return types.TArray{Typ: args[0].ResolvedType()} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A concern I have with this now is that it effectively creates undocumented overloads for array_agg
for types that are aliased to types with defined overloads. It might not be a big issue since this function's behaviour is fairly straightforward, but I wanted to at least mention it.
dbb5d07
to
e592b68
Compare
As referenced in cockroachdb#15939, ARRAY_AGG erroneously returns `anyelement` as its fixed return type. This follows the convention of existing array builtin functions to have overloads for all non-array types, which allows the fixed return type to be known for each overload. Whenever possible, we still use the expression's type so that aliases without explicit overloads return the expected type. Release note (bug fix): None
e592b68
to
41f88bb
Compare
As referenced in #15939, ARRAY_AGG erroneously returns
anyelement
as its fixed return type. This follows the convention of existing array builtin functions to have overloads for all non-array types, which allows the fixed return type to be known for each overload.Release note (bug fix): None