cockroachdb / cockroachdb/cockroach

optbuilder: star expansion in UDFs produces duplicate column names

Open
#112,942 0 comments 0 reactions 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.