Skip to content

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!

@haines haines force-pushed the unnest-with-ordinality branch from 9d48aa8 to 9f172ce Compare April 12, 2023 17:33
@haines haines force-pushed the unnest-with-ordinality branch from 9f172ce to c7a10a7 Compare April 27, 2023 19:31
…ning unknown types

Signed-off-by: Andrew Haines <andrew@haines.org.nz>
@haines haines force-pushed the unnest-with-ordinality branch from c7a10a7 to 7234229 Compare June 6, 2023 14:35
@kyleconroy kyleconroy merged commit 734e06e into sqlc-dev:main Jun 9, 2023
@haines haines deleted the unnest-with-ordinality branch June 13, 2023 14:13
alfonsodev pushed a commit to ExponentiaTeam/sqlc that referenced this pull request Oct 13, 2025
…ning unknown types (sqlc-dev#2156)

Signed-off-by: Andrew Haines <andrew@haines.org.nz>
Co-authored-by: Kyle Conroy <kyle@conroy.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants