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

feat: Allow use of table and column aliases for table functions returning unknown types #2156

Merged
merged 2 commits into from Jun 9, 2023

Conversation

haines
Copy link
Contributor

@haines haines commented Mar 17, 2023

At the moment, when a table function returns a type that isn't a known table, it's excluded from the output columns completely. This makes it impossible to use unnest() or unnest() WITH ORDINALITY with a table alias (#1205, #1596).

This PR allows constructs such as

SELECT foo.bar FROM unnest(baz) AS foo (bar);

and

SELECT foo.bar, foo.i::bigint FROM unnest(baz) WITH ORDINALITY AS foo (bar, i);

I haven't attempted to solve this problem in general - it will only work for a table alias with column alias(es), and data types are any, necessitating casts. This seems like a good first step, at least.

Fixes #1205

@StevenACoffman
Copy link
Contributor

I really appreciate your continued work on this area, as you appear to be fixing our biggest pain points! This and your work on #1884 are much appreciated, and I hope both can get reviewed and merged soon!

@haines
Copy link
Contributor Author

haines commented Mar 24, 2023

Thanks @StevenACoffman, I'm glad this is helpful!

…ning unknown types

Signed-off-by: Andrew Haines <andrew@haines.org.nz>
@kyleconroy kyleconroy merged commit 734e06e into sqlc-dev:main Jun 9, 2023
6 checks passed
@haines haines deleted the unnest-with-ordinality branch June 13, 2023 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Column not found when using WITH ORDINALITY clause
3 participants