-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Support index acess for Row Type #7640
Comments
Good idea! But I think we should only allow constant index, otherwise it will be hard to infer the field type. |
Looking at how PostgreSQL and Oracle solve the problem. In Postgre SQL, the row constructor will construct an
If I understand correctly, the only way to extract specific field from an unnamed record is to cast it into a defined
Would like to hear any comments/suggestions from people who are more familiar with PostgreSQL :). |
In Oracle, the Previous SQL engine doesn't have the same flexibility as Presto to get unnamed RowType. As such, accessing field in unnamed RowType is not a pain point for them. We plan to add constant subscript access support for RowType in Presto |
Index access seems strange given that it must be constant. It's really a tuple, not an array. What about generating well-known synthetic field names? For example, f1, f2, or c1, c2, etc. This makes it obvious they are constant field accesses and not array accesses.
|
@electrum We probably want to use something that cannot be a legal field name then :). What about |
No, you want it to be easy to access. There's no problem with conflicts since you can't have a partially anonymous row. They're either all named or none are.
|
That's not true. They type of a "relation" is multiset(row(...)). If that relation is a subquery, some fields may be unnamed (e.g., if they are the result of some complex expression and don't have an alias) |
I think we should hold off adding this feature for now. I really don't like the idea of adding synthetic fields with some arbitrary name, and the subscript operator version has enough edge cases and potential complications that we need to think about it very carefully. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Today we only support access by field for Row Type. For row types without field types, we have to first cast it into a Row with field names:
It will be nice to support index access, i.e.
v[1]
will return the first field of the row.The text was updated successfully, but these errors were encountered: