[ 
https://issues.apache.org/jira/browse/PHOENIX-7274?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Rajeshbabu Chintaguntla updated PHOENIX-7274:
---------------------------------------------
    Description: 
There is possible column ambiguity when column alias name is same as column 
name and used in some operators or cast.
DDLs created from joins examples below.
https://phoenix.apache.org/joins.html

{code:java}
0: jdbc:phoenix:> select * from (select cast(customerid as char(10)) as 
customerid from orders) as tt union all select * from (select cast(customerid 
as char(10)) as customerid from customers) as nn;
Error: ERROR 502 (42702): Column reference ambiguous or duplicate names. 
columnName=CUSTOMERID (state=42702,code=502)
org.apache.phoenix.schema.AmbiguousColumnException: ERROR 502 (42702): Column 
reference ambiguous or duplicate names. columnName=CUSTOMERID
        at 
org.apache.phoenix.parse.ParseNodeRewriter.visit(ParseNodeRewriter.java:461)
        at 
org.apache.phoenix.compile.SubselectRewriter.visit(SubselectRewriter.java:578)
        at 
org.apache.phoenix.compile.SubselectRewriter.visit(SubselectRewriter.java:58)
        at 
org.apache.phoenix.parse.ColumnParseNode.accept(ColumnParseNode.java:56)
        at 
org.apache.phoenix.parse.CompoundParseNode.acceptChildren(CompoundParseNode.java:64)
        at org.apache.phoenix.parse.CastParseNode.accept(CastParseNode.java:60)
        at 
org.apache.phoenix.parse.ParseNodeRewriter.rewrite(ParseNodeRewriter.java:112)
        at 
org.apache.phoenix.compile.SubselectRewriter.flatten(SubselectRewriter.java:570)
        at 
org.apache.phoenix.compile.SubselectRewriter.flatten(SubselectRewriter.java:353)
        at org.apache.phoenix.util.ParseNodeUtil.rewrite(ParseNodeUtil.java:175)
        at 
org.apache.phoenix.compile.QueryCompiler.compileSubquery(QueryCompiler.java:644)
        at 
org.apache.phoenix.compile.QueryCompiler.compileUnionAll(QueryCompiler.java:222)
        at 
org.apache.phoenix.compile.QueryCompiler.compile(QueryCompiler.java:176)
        at 
org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:547)
        at 
org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:510)
        at 
org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:314)
        at 
org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:303)
        at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
        at 
org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:302)
        at 
org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:295)
        at 
org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:2061)
        at sqlline.Commands.executeSingleQuery(Commands.java:1054)
        at sqlline.Commands.execute(Commands.java:1003)
        at sqlline.Commands.sql(Commands.java:967)
        at sqlline.SqlLine.dispatch(SqlLine.java:734)
        at sqlline.SqlLine.begin(SqlLine.java:541)
        at sqlline.SqlLine.start(SqlLine.java:267)
        at sqlline.SqlLine.main(SqlLine.java:206){code}


  was:
There is possible column ambiguity when column alias name is same as column 
name and used in some operators or cast similarly getting NPE also

{code:java}
0: jdbc:phoenix:> select * from (select cast(customerid as char(10)) as 
customerid from orders) as tt union all select * from (select cast(customerid 
as char(10)) as customerid from customers) as nn;
Error: ERROR 502 (42702): Column reference ambiguous or duplicate names. 
columnName=CUSTOMERID (state=42702,code=502)
org.apache.phoenix.schema.AmbiguousColumnException: ERROR 502 (42702): Column 
reference ambiguous or duplicate names. columnName=CUSTOMERID
        at 
org.apache.phoenix.parse.ParseNodeRewriter.visit(ParseNodeRewriter.java:461)
        at 
org.apache.phoenix.compile.SubselectRewriter.visit(SubselectRewriter.java:578)
        at 
org.apache.phoenix.compile.SubselectRewriter.visit(SubselectRewriter.java:58)
        at 
org.apache.phoenix.parse.ColumnParseNode.accept(ColumnParseNode.java:56)
        at 
org.apache.phoenix.parse.CompoundParseNode.acceptChildren(CompoundParseNode.java:64)
        at org.apache.phoenix.parse.CastParseNode.accept(CastParseNode.java:60)
        at 
org.apache.phoenix.parse.ParseNodeRewriter.rewrite(ParseNodeRewriter.java:112)
        at 
org.apache.phoenix.compile.SubselectRewriter.flatten(SubselectRewriter.java:570)
        at 
org.apache.phoenix.compile.SubselectRewriter.flatten(SubselectRewriter.java:353)
        at org.apache.phoenix.util.ParseNodeUtil.rewrite(ParseNodeUtil.java:175)
        at 
org.apache.phoenix.compile.QueryCompiler.compileSubquery(QueryCompiler.java:644)
        at 
org.apache.phoenix.compile.QueryCompiler.compileUnionAll(QueryCompiler.java:222)
        at 
org.apache.phoenix.compile.QueryCompiler.compile(QueryCompiler.java:176)
        at 
org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:547)
        at 
org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:510)
        at 
org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:314)
        at 
org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:303)
        at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
        at 
org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:302)
        at 
org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:295)
        at 
org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:2061)
        at sqlline.Commands.executeSingleQuery(Commands.java:1054)
        at sqlline.Commands.execute(Commands.java:1003)
        at sqlline.Commands.sql(Commands.java:967)
        at sqlline.SqlLine.dispatch(SqlLine.java:734)
        at sqlline.SqlLine.begin(SqlLine.java:541)
        at sqlline.SqlLine.start(SqlLine.java:267)
        at sqlline.SqlLine.main(SqlLine.java:206){code}



> Possible column ambiguity error with union all queries when column used in 
> any operators and result aliased to same column
> --------------------------------------------------------------------------------------------------------------------------
>
>                 Key: PHOENIX-7274
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-7274
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: Rajeshbabu Chintaguntla
>            Assignee: Rajeshbabu Chintaguntla
>            Priority: Major
>
> There is possible column ambiguity when column alias name is same as column 
> name and used in some operators or cast.
> DDLs created from joins examples below.
> https://phoenix.apache.org/joins.html
> {code:java}
> 0: jdbc:phoenix:> select * from (select cast(customerid as char(10)) as 
> customerid from orders) as tt union all select * from (select cast(customerid 
> as char(10)) as customerid from customers) as nn;
> Error: ERROR 502 (42702): Column reference ambiguous or duplicate names. 
> columnName=CUSTOMERID (state=42702,code=502)
> org.apache.phoenix.schema.AmbiguousColumnException: ERROR 502 (42702): Column 
> reference ambiguous or duplicate names. columnName=CUSTOMERID
>       at 
> org.apache.phoenix.parse.ParseNodeRewriter.visit(ParseNodeRewriter.java:461)
>       at 
> org.apache.phoenix.compile.SubselectRewriter.visit(SubselectRewriter.java:578)
>       at 
> org.apache.phoenix.compile.SubselectRewriter.visit(SubselectRewriter.java:58)
>       at 
> org.apache.phoenix.parse.ColumnParseNode.accept(ColumnParseNode.java:56)
>       at 
> org.apache.phoenix.parse.CompoundParseNode.acceptChildren(CompoundParseNode.java:64)
>       at org.apache.phoenix.parse.CastParseNode.accept(CastParseNode.java:60)
>       at 
> org.apache.phoenix.parse.ParseNodeRewriter.rewrite(ParseNodeRewriter.java:112)
>       at 
> org.apache.phoenix.compile.SubselectRewriter.flatten(SubselectRewriter.java:570)
>       at 
> org.apache.phoenix.compile.SubselectRewriter.flatten(SubselectRewriter.java:353)
>       at org.apache.phoenix.util.ParseNodeUtil.rewrite(ParseNodeUtil.java:175)
>       at 
> org.apache.phoenix.compile.QueryCompiler.compileSubquery(QueryCompiler.java:644)
>       at 
> org.apache.phoenix.compile.QueryCompiler.compileUnionAll(QueryCompiler.java:222)
>       at 
> org.apache.phoenix.compile.QueryCompiler.compile(QueryCompiler.java:176)
>       at 
> org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:547)
>       at 
> org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:510)
>       at 
> org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:314)
>       at 
> org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:303)
>       at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
>       at 
> org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:302)
>       at 
> org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:295)
>       at 
> org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:2061)
>       at sqlline.Commands.executeSingleQuery(Commands.java:1054)
>       at sqlline.Commands.execute(Commands.java:1003)
>       at sqlline.Commands.sql(Commands.java:967)
>       at sqlline.SqlLine.dispatch(SqlLine.java:734)
>       at sqlline.SqlLine.begin(SqlLine.java:541)
>       at sqlline.SqlLine.start(SqlLine.java:267)
>       at sqlline.SqlLine.main(SqlLine.java:206){code}



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

Reply via email to