[ 
https://issues.apache.org/jira/browse/CALCITE-5583?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17974025#comment-17974025
 ] 

Julian Hyde commented on CALCITE-5583:
--------------------------------------

I think this behavior should be dialect-specific. Most dialects allow top-level 
queries to return duplicate column names; Postgres might be the exception here.

Quite a few tests have been made significantly more verbose in this change.  
E.g. testSimpleJoinConditionWithIsNullOperators. Verbose tests add to tech 
debt. Change the SELECT clause of those tests to make them less verbose.

I don't see a reason for the two versions of {{Util.isDistinct}} to use 
different strategies. Add {{caseSensitive}} parameter to {{firstDupliciate}}. 
It should have a quick loop that uses {{equalsIgnoreCase}}.

> JDBC adapter generates 'SELECT *', which is invalid SQL if there are 
> duplicate column names
> -------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-5583
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5583
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: libopeng
>            Assignee: libopeng
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> JDBC adapter generates 'SELECT *', which is invalid SQL if there are 
> duplicate column names
> {code:java}
> LogicalProject(c0=[$0], c00=[$1])
>   LogicalJoin(condition=[=($0, $1)], joinType=[inner])
>     LogicalProject(c0=[$0])
>       LogicalTableScan(table=[[scott, EMP]])
>     LogicalProject(c0=[$0])
>       LogicalTableScan(table=[[scott, EMP]]){code}
> to sql
> {code:java}
> SELECT *
> FROM (SELECT "EMPNO" AS "c0"
> FROM "scott"."EMP") AS "t"
> INNER JOIN (SELECT "EMPNO" AS "c0"
> FROM "scott"."EMP") AS "t0" ON "t"."c0" = "t0"."c0" {code}
> When this sql is a subquery, it can be wrong
> {code:java}
> select *
> from "EMPNO" t1
> left join (
> SELECT * FROM (SELECT "EMPNO" AS "c0" FROM "scott"."EMP") AS "t" INNER JOIN 
> (SELECT "EMPNO" AS "c0" FROM "scott"."EMP") AS "t0" ON "t"."c0" = "t0"."c0" 
> ) t2
> on t1.EMPNO=t2."c0"{code}
> {color:#ff0000}fault: 'column reference "c0" is ambiguous' error when 
> executing in postgresql{color}
>  
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to