[ https://issues.apache.org/jira/browse/CALCITE-5588?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17705163#comment-17705163 ]
Benchao Li commented on CALCITE-5588: ------------------------------------- Agree with [~julianhyde] , the problem should be in the "on not exist". IMO, this is a similar issue with CALCITE-4913, that we should deduplicate the variables used more than once for {{Join}} condition too. > ArrayIndexOutOfBoundsException on select > ---------------------------------------- > > Key: CALCITE-5588 > URL: https://issues.apache.org/jira/browse/CALCITE-5588 > Project: Calcite > Issue Type: Bug > Affects Versions: 1.33.0 > Reporter: Magnus Mogren > Priority: Major > > Execute this SQL > {code:java} > select Header.Name from ( VALUES (1, 'A'), (2, 'B')) as Header(Id, Name) join > (values (11, 1), (12, 1), (21, 2)) as Version(Id, Parent) on not exists > (select 1 from (values (11, 1), (12, 1), (21, 2)) as Version2(Id, Parent) > where Version2.Parent = Header.Id and Version2.Id > Version.Id) {code} > > *Expected result* > A ResultSet containing this > |*NAME*| > |A| > |A| > |B| > > *Actual result* > {color:#FF0000}ArrayIndexOutOfBoundsException: Index 2 out of bounds for > length 2{color} -- This message was sent by Atlassian Jira (v8.20.10#820010)