Uploaded image for project: 'Teiid'
  1. Teiid
  2. TEIID-1577

ArrayIndexOutOfBoundsException in queries with ORDER BY

    XMLWordPrintable

Details

    Description

      The models are almost the same described in https://issues.jboss.org/browse/TEIID-1576. There's a global view model (named "aop") that integrates the data from three view models (using a UNION ALL operator). It has been already described in https://issues.jboss.org/browse/TEIID-1562.

      When I run the following query I get an IndexOutOfBoundsException:

      SELECT
          codop,
          codice,
          data,
          codref,
          groupdim
      FROM
          aop.misura124.aop.vendita_referenza
      order by data asc
      

      The content of the log file is the following:

      2011-05-04 17:36:38,681 DEBUG [org.teiid.COMMAND_LOG] (New I/O server worker #1-1) 	START USER COMMAND:	startTime=2011-05-04 17:36:38.681	requestID=fvJwLRknMQEc.2	txID=null	sessionID=fvJwLRknMQEc	applicationName=JDBC	principal=admin@teiid-security	vdbName=misura124	vdbVersion=1	sql=SELECT VDBName AS TABLE_CAT, SchemaName AS TABLE_SCHEM, Name AS TABLE_NAME, CASE WHEN IsSystem = 'true' and UCASE(Type) = 'TABLE' THEN 'SYSTEM TABLE' ELSE UCASE(Type) END AS TABLE_TYPE, Description AS REMARKS, NULL AS TYPE_CAT, NULL AS TYPE_SCHEM, NULL AS TYPE_NAME, NULL AS SELF_REFERENCING_COL_NAME, NULL AS REF_GENERATION, IsPhysical AS ISPHYSICAL FROM SYS.Tables g  WHERE UCASE(VDBName) LIKE ? ESCAPE '\'  AND UCASE(SchemaName) LIKE ? ESCAPE '\'  AND UCASE(Name) LIKE ? ESCAPE '\'  AND (CASE WHEN IsSystem = 'true' and UCASE(Type) = 'TABLE' THEN 'SYSTEM TABLE' ELSE UCASE(Type) END LIKE ? ESCAPE '\' ) ORDER BY TABLE_TYPE, TABLE_SCHEM, TABLE_NAME
          codop,
          codice,
          data,
          codref,
          groupdim
      FROM
          aop.misura124.aop.vendita_referenza
      order by data asc
      2011-05-04 17:36:40,071 DEBUG [org.teiid.COMMAND_LOG] (Worker1_QueryProcessorQueue6) 	ERROR USER COMMAND:	endTime=2011-05-04 17:36:40.071	requestID=qaDAPpF9gmnN.0	txID=null	sessionID=qaDAPpF9gmnN	principal=admin@teiid-security	vdbName=misura124	vdbVersion=1	finalRowCount=null
      2011-05-04 17:36:40,071 ERROR [org.teiid.PROCESSOR] (Worker1_QueryProcessorQueue6) Unexpected exception for request qaDAPpF9gmnN.0
      java.lang.ArrayIndexOutOfBoundsException: -1
      	at java.util.ArrayList.get(ArrayList.java:324)
      	at org.teiid.query.optimizer.relational.rules.RuleMergeVirtual.checkForSimpleProjection(RuleMergeVirtual.java:288)
      	at org.teiid.query.optimizer.relational.rules.RuleMergeVirtual.doMerge(RuleMergeVirtual.java:158)
      	at org.teiid.query.optimizer.relational.rules.RuleMergeVirtual.execute(RuleMergeVirtual.java:73)
      	at org.teiid.query.optimizer.relational.RelationalPlanner.executeRules(RelationalPlanner.java:460)
      	at org.teiid.query.optimizer.relational.RelationalPlanner.optimize(RelationalPlanner.java:225)
      	at org.teiid.query.optimizer.QueryOptimizer.optimizePlan(QueryOptimizer.java:192)
      	at org.teiid.dqp.internal.process.Request.generatePlan(Request.java:429)
      	at org.teiid.dqp.internal.process.Request.processRequest(Request.java:452)
      	at org.teiid.dqp.internal.process.RequestWorkItem.processNew(RequestWorkItem.java:425)
      	at org.teiid.dqp.internal.process.RequestWorkItem.process(RequestWorkItem.java:224)
      	at org.teiid.dqp.internal.process.AbstractWorkItem.run(AbstractWorkItem.java:56)
      	at org.teiid.dqp.internal.process.DQPWorkContext.runInContext(DQPWorkContext.java:197)
      	at org.teiid.dqp.internal.process.ThreadReuseExecutor$RunnableWrapper.run(ThreadReuseExecutor.java:118)
      	at org.teiid.dqp.internal.process.ThreadReuseExecutor$3.run(ThreadReuseExecutor.java:288)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      	at java.lang.Thread.run(Thread.java:662)
      

      If I remove the GROUP BY statement, the query works. I also tried to sort on other fields, but the result doesn't change. As always, I've reduced the models in order to highlight where the problem is. I attach the project which contains them.

      Attachments

        Activity

          People

            rhn-engineering-shawkins Steven Hawkins
            ventuc Claudio Venturini (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: