Re: Targetlist lost when CTE join

2023-06-28 Thread Zhang Mingli
HI, On Jun 28, 2023, 17:26 +0800, Julien Rouhaud , wrote: > On Wed, Jun 28, 2023 at 05:17:14PM +0800, Julien Rouhaud wrote: > > > > > > Table t1 and  t2 both has 2 columns: c1, c2, when CTE join select *, the > > > result target list seems to lost one’s column c1. > > > But it looks good when sel

Re: Targetlist lost when CTE join

2023-06-28 Thread Julien Rouhaud
On Wed, Jun 28, 2023 at 05:17:14PM +0800, Julien Rouhaud wrote: > > > > Table t1 and  t2 both has 2 columns: c1, c2, when CTE join select *, the > > result target list seems to lost one’s column c1. > > But it looks good when select cte1.* and t1.* explicitly . > > > > Is it a bug? > > This is wor

Re: Targetlist lost when CTE join

2023-06-28 Thread Zhang Mingli
Hi Regards, Zhang Mingli On Jun 28, 2023, 17:17 +0800, Julien Rouhaud , wrote: > This is working as intended. When using a USING clause you "merge" both > columns so the final target list only contain one version of the merged > columns, which doesn't happen if you use e.g. ON instead. I'm assumin

Re: Targetlist lost when CTE join

2023-06-28 Thread Julien Rouhaud
Hi, On Wed, Jun 28, 2023 at 04:52:34PM +0800, Zhang Mingli wrote: > > Mini repo > > create table t1(c1 int, c2 int); > CREATE TABLE > create table t2(c1 int, c2 int); > CREATE TABLE > explain with cte1 as (insert into t2 values (1, 2) returning *) select * from > cte1 join t1 using(c1); >  QUERY

Re: Targetlist lost when CTE join

2023-06-28 Thread Zhang Mingli
Hi, Explain verbose, seems HashJoin node drop that column. gpadmin=# explain(verbose) with cte1 as (insert into t2 values (1, 2) returning *) select * from cte1 join t1 using(c1);  QUERY PLAN ---  Hash Join (cost=0.04..41.23 rows=1

Targetlist lost when CTE join

2023-06-28 Thread Zhang Mingli
Hi, Mini repo create table t1(c1 int, c2 int); CREATE TABLE create table t2(c1 int, c2 int); CREATE TABLE explain with cte1 as (insert into t2 values (1, 2) returning *) select * from cte1 join t1 using(c1);  QUERY PLAN  Hash Join