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

James Duong edited comment on CALCITE-6369 at 4/29/24 10:41 PM:
----------------------------------------------------------------

I've reproduced this problem. It's not clear why there's an 
ArrayIndexOutOfBoundsException while doing the permute call.

What happens is that the select expansion is converting the r_regionkey column 
reference to a COALESCE(r0.r_regionky, r1.r_regionkey) and gives it the alias 
EMPNO – I'm guessing this is because NULL won't be matched when the column is 
joined.

If I forcibly change permute to get past the AIOB (stopping permutation at the 
faulty index), I get an ambiguous column reference error, which seems like a 
reasonable result for this query.

 


was (Author: jduong):
I've reproduced this problem. It's not clear why there's an 
ArrayIndexOutOfBoundsException while doing the permute call.

What happens is that the select expansion is converting the r_regionkey column 
reference to a COALESCE(r0.r_regionky, r1.r_regionkey) – I'm guessing this is 
because NULL won't be matched when the column is joined.

If I forcibly change permute to get past the AIOB (stopping permutation at the 
faulty index), I get an ambiguous column reference error, which seems like a 
reasonable result for this query.

 

> Expanding "star" gives ArrayIndexOutOfBoundsException with redundant columns 
> and USING
> --------------------------------------------------------------------------------------
>
>                 Key: CALCITE-6369
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6369
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.36.0
>            Reporter: Claude Brisson
>            Assignee: James Duong
>            Priority: Major
>
> The query
> {code}
> select r_regionkey, * from region r0 join region r1 using (r_regionkey)
> {code}
> produces
> {code}
> java.lang.ArrayIndexOutOfBoundsException: Index 14 out of bounds for length 14
>     at org.apache.calcite.runtime.PairLists$ArrayImmutablePairList.get 
> (PairLists.java:573)
>     at org.apache.calcite.runtime.PairLists$ArrayImmutablePairList.get 
> (PairLists.java:550)
>     at org.apache.calcite.sql.validate.SqlValidatorImpl$Permute.permute 
> (SqlValidatorImpl.java:7443)
>     at org.apache.calcite.sql.validate.SqlValidatorImpl.expandStar 
> (SqlValidatorImpl.java:697)
>     at org.apache.calcite.sql.validate.SqlValidatorImpl.expandSelectItem 
> (SqlValidatorImpl.java:453)
>     at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelectList 
> (SqlValidatorImpl.java:4658)
>     at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect 
> (SqlValidatorImpl.java:3840)
>     at org.apache.calcite.sql.validate.SelectNamespace.validateImpl 
> (SelectNamespace.java:61)
>     at org.apache.calcite.sql.validate.AbstractNamespace.validate 
> (AbstractNamespace.java:88)
>     at org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace 
> (SqlValidatorImpl.java:1154)
>     at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery 
> (SqlValidatorImpl.java:1125)
> {code}



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

Reply via email to