-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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: typing of multi-row subqueries is confusing #21124
Comments
See #21273 for a related issue in |
@RaduBerinde this seems like a planning issue, moving to your project. |
Leaving some notes about this:
|
We have marked this issue as stale because it has been inactive for |
Multi-row subqueries are currently typed as
tuple{U}
. This plays nicely with the type checking code which can thus treat a multi-row subquery very similarly to atuple
, but is wrong semantically. The subquery has a variable number of elements, whiletuple{U}
is specifying a fixed length tuple with 1 element. That this works is due to misuse of thetuple
type in the type checking code. SeetypeCheckSubqueryWithIn
.Instead of using
tuple{U}
, multi-row subqueries should be typed with a variable length type such astable{U}
orvtuple{U}
(variable tuple). The existingtypes.TTable
type seems to fit the bill, though there is mild concern due to the existing usage of that type for set-returning-functions (e.g.generate_series
).In order to change the type of multi-row subqueries, the type checking code for
IN
,NOT IN
,ALL
,SOME
,ANY
andARRAY
needs to change. This is currently non-trivial. For example, there currently exists an overload for<tuple> IN <tuple>
. Would we also need an overload for<tuple> IN <table>
? There are also bits of special type checking code which look fortypes.TTuple
which would need to be generalized. See #21123 for additional commentary on the type checking code.Cc @nvanbenschoten, @knz
Jira issue: CRDB-5899
The text was updated successfully, but these errors were encountered: