Skip to content
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

Positional access to fields in anonymous Row #860

Closed
findepi opened this issue May 31, 2019 · 2 comments

Comments

3 participants
@findepi
Copy link
Member

commented May 31, 2019

It's very easy to construct an unnamed/anonymous Row:

row(value1, value2, value3)
(value1, value2, value3)

Also, some connectors return rows with unnamed fields (e.g. #416)

Currently, accessing an individual value in such a row is not convenient: it requires casting to a named row, so user needs to name all the fields and their types. This verbosity brings no additional benefit.

Let's provide a way to access fields in anonymous Row in a convenient fashion.

See previous discussion: #416 (comment)

@findepi

This comment has been minimized.

Copy link
Member Author

commented May 31, 2019

@martint proposed in #416 (comment) that we use subscript operator

For a long time I've been thinking we might want to add support for positional access for row types (as an extension to standard SQL). This could easily be done by allowing row types to support the subscript operator: e.g., x[1].

I like this idea.
For this, we should allow only integer literals in the subscript, so that we can analyze the types correctly.

@martint

This comment has been minimized.

Copy link
Member

commented May 31, 2019

I think it's the cleanest way to implement this. It doesn't require additional syntax or non-standard language constructs, and it's semantically consistent with arrays and maps. The only weird aspect is the requirement that the subscript be a constant, so it's not completely seamless vs subscript for other types.

@kasiafi kasiafi self-assigned this Jun 1, 2019

@martint martint closed this in #895 Jun 4, 2019

@martint martint added this to the 314 milestone Jun 4, 2019

@martint martint referenced this issue Jun 4, 2019

Closed

Release notes for 314 #879

2 of 6 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.