citusdata / citusdata/citus

error in propogating select queries with casted columns to workers

Open
#4,014 1 comment 0 reactions 0 assignees View on GitHub
bug sqlancer
Dominant language
C
Stars
12.8k
Forks
794
Avg merge
2d 14h
Merged PRs (30d)
31

Description

The SELECT query below can be executed on a local table, but it gives the following error when executed on a reference table:
```
CREATE TABLE t0(c0 TEXT);
SELECT create_reference_table('t0');
SELECT t0.c0, (t0.c0)::BOOLEAN FROM t0 GROUP BY t0.c0 ORDER BY t0.c0 DESC;
ERROR: ORDER BY "c0" is ambiguous
```
Here is the log output of queries sent to worker nodes:
```
[local] v-naugur@postgres:9700-3296=# SELECT t0.c0, (t0.c0)::BOOLEAN FROM t0 GROUP BY t0.c0 ORDER BY t0.c0 DESC;
NOTICE: issuing SELECT c0, (c0)::boolean AS c0 FROM public.t0_102280 t0 GROUP BY c0 ORDER BY c0 DESC
DETAIL: on server v-naugur@localhost:9701 connectionId: 11
ERROR: ORDER BY "c0" is ambiguous
CONTEXT: while executing command on localhost:9701
Time: 4.162 ms
```
The error is likely related to the definition: `(c0)::boolean AS c0`, which results in 2 conflicting `c0` columns in the same SELECT query and thus makes ordering on `c0` ambiguous.

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.