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

sql: query works in Postgres but not CockroachDB #59154

Closed
RichardJCai opened this issue Jan 19, 2021 · 1 comment
Closed

sql: query works in Postgres but not CockroachDB #59154

RichardJCai opened this issue Jan 19, 2021 · 1 comment
Labels
A-sql-name-resolution SQL name resolution rules and CTEs. A-sql-syntax Issues strictly related to the SQL grammar, with no semantic aspect C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)

Comments

@RichardJCai
Copy link
Contributor

RichardJCai commented Jan 19, 2021

This was found during Hack the North, a hacker found that the following setup/query would work on PG13 but not CRDB.

Setup

drop table if exists pplArr;
create table pplArr(uid text primary key, languages text[]);
insert into pplArr (uid, languages) values
('allen','{go,python,java,swift}'),
('em','{python,java,swift}'),
('aman','{go,python,java}'),
('harp','{python,java,swift}');

Query

select uid, count(lang) as common_elements
from pplArr p
cross join unnest(p.languages) as lang
where lang = any('{go,java,python}')
group by 1;

The query succeeds in PG but gives ERROR: no data source matches prefix: p in this context in CRDB

@RichardJCai RichardJCai added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. A-sql-syntax Issues strictly related to the SQL grammar, with no semantic aspect labels Jan 19, 2021
@rafiss rafiss added the A-sql-name-resolution SQL name resolution rules and CTEs. label Jan 26, 2021
@rafiss rafiss added the T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) label May 12, 2021
@rafiss
Copy link
Collaborator

rafiss commented Sep 17, 2021

closing in favor of #70342

@rafiss rafiss closed this as completed Sep 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-name-resolution SQL name resolution rules and CTEs. A-sql-syntax Issues strictly related to the SQL grammar, with no semantic aspect C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)
Projects
None yet
Development

No branches or pull requests

2 participants