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

Benjamin Lerer commented on CASSANDRA-18386:
--------------------------------------------

The problem is more complex than it looks at first. 
{{SelectStatement.queriedColumns}} is obviously broken. Any query that use bind 
variables will break on this method. It was not a problem in the past because 
that method was only used for Materialized Views that do not use bind  
variables. The error show up because the method is now used by {{asCQL}}.
I would like to mention here that {{asCQL}} should not exist. When a query 
string is needed we should always use the original one and not attempt to 
recreate one as this one might differ from the original query and will probably 
differ more and more in the future as we will start rewriting queries more and 
more for optimization purpose.
I believe that we need to do 2 things here:
# remove the asCQL method
# fix the {{queriedColumns}} method or refactor the code to make it clear that 
the method is only for MVs or queries that do not have bind variables.

Removing the LHF flag as it is probably not a LHF ticket.


> SelectStatement.asCQL fails with IndexOutOfBoundsException
> ----------------------------------------------------------
>
>                 Key: CASSANDRA-18386
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-18386
>             Project: Cassandra
>          Issue Type: Bug
>          Components: CQL/Interpreter
>            Reporter: David Capwell
>            Priority: Normal
>             Fix For: 4.1.x, 5.x
>
>
> See 
> https://app.circleci.com/pipelines/github/dcapwell/cassandra/1934/workflows/2525f75d-a819-43db-8e89-c9d58cc8f4d7/jobs/18594
> {code}
> java.lang.IndexOutOfBoundsException: Index: 0
>       at java.util.Collections$EmptyList.get(Collections.java:4456)
>       at 
> org.apache.cassandra.cql3.Constants$Marker.bindAndGet(Constants.java:470)
>       at 
> org.apache.cassandra.cql3.selection.ElementsSelector$1.newInstance(ElementsSelector.java:129)
>       at 
> org.apache.cassandra.cql3.selection.SelectorFactories.newInstances(SelectorFactories.java:206)
>       at 
> org.apache.cassandra.cql3.selection.Selection$SelectionWithProcessing$1.<init>(Selection.java:564)
>       at 
> org.apache.cassandra.cql3.selection.Selection$SelectionWithProcessing.newSelectors(Selection.java:562)
>       at 
> org.apache.cassandra.cql3.statements.SelectStatement.queriedColumns(SelectStatement.java:195)
>       at 
> org.apache.cassandra.cql3.statements.SelectStatement.asCQL(SelectStatement.java:1634)
> {code}



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

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to