cockroachdb / cockroachdb/cockroach
optbuilder: star expansion in UDFs produces duplicate column names
Open
A-sql-routine
C-bug
T-sql-queries
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
When a routine is created, we expand the star expressions (all-columns selector) into the referenced column names. However, the following example shows a case where we generate duplicate names, which leads to an error upon trying to resolve the expanded query:
```
CREATE FUNCTION f() RETURNS RECORD LANGUAGE SQL AS $$ SELECT * FROM UNNEST('{"a","b","c"}'::TEXT[], '{"d", "e","f"}'::TEXT[]) $$;
ERROR: column reference "unnest" is ambiguous (candidates: .unnest)
SQLSTATE: 42702
```
Jira issue: CRDB-32684
Contributor guide
Assessment
This issue has not been assessed yet.