Uploaded image for project: 'Apache AsterixDB'
  1. Apache AsterixDB
  2. ASTERIXDB-1298

IndexOutOfBounds when joining through function

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      The following gives an IndexOutOfBounds exception:

      drop dataverse channels if exists;
      create dataverse channels;
      use dataverse channels;
      
      create type userLocation as closed {
      	userId: int,
      	roomNumber: int
      }
      create dataset userLocations(userLocation)
      primary key userId;
      
      create function currentOccupancy($room) {
      		let $list := for $location in dataset userLocations where $location.roomNumber = $room return $location.userId
      		return $list
      };
      
      upsert into dataset userLocations(
      [{"userId":1, "roomNumber":123},
      {"userId":2, "roomNumber":123},
      {"userId":3, "roomNumber":123},
      {"userId":4, "roomNumber":123},
      {"userId":5, "roomNumber":350},
      {"userId":6, "roomNumber":350},
      {"userId":7, "roomNumber":350},
      {"userId":8, "roomNumber":350},
      {"userId":9, "roomNumber":350},
      {"userId":10,"roomNumber":210},
      {"userId":11,"roomNumber":210},
      {"userId":12,"roomNumber":210},
      {"userId":13,"roomNumber":210},
      {"userId":14,"roomNumber":210}]
      );
      
      create type subscription as {
      	"id":uuid,
      	"param0":int
      }
      create dataset subscriptions(subscription)
      primary key id autogenerated;
      
      insert into dataset subscriptions({"param0":123});
      
      for $sub in dataset subscriptions
      for $result in currentOccupancy($sub.param0)
      return $result;
      

      Error information

      SEVERE: Index: 0, Size: 0
      java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
      	at java.util.ArrayList.rangeCheck(ArrayList.java:653)
      	at java.util.ArrayList.get(ArrayList.java:429)
      	at org.apache.asterix.optimizer.rules.subplan.InlineSubplanInputForNestedTupleSourceRule.applySpecialFlattening(InlineSubplanInputForNestedTupleSourceRule.java:523)
      	at org.apache.asterix.optimizer.rules.subplan.InlineSubplanInputForNestedTupleSourceRule.rewriteSubplanOperator(InlineSubplanInputForNestedTupleSourceRule.java:285)
      	at org.apache.asterix.optimizer.rules.subplan.InlineSubplanInputForNestedTupleSourceRule.traverseNonSubplanOperator(InlineSubplanInputForNestedTupleSourceRule.java:313)
      	at org.apache.asterix.optimizer.rules.subplan.InlineSubplanInputForNestedTupleSourceRule.rewriteSubplanOperator(InlineSubplanInputForNestedTupleSourceRule.java:280)
      	at org.apache.asterix.optimizer.rules.subplan.InlineSubplanInputForNestedTupleSourceRule.traverseNonSubplanOperator(InlineSubplanInputForNestedTupleSourceRule.java:313)
      	at org.apache.asterix.optimizer.rules.subplan.InlineSubplanInputForNestedTupleSourceRule.rewriteSubplanOperator(InlineSubplanInputForNestedTupleSourceRule.java:280)
      	at org.apache.asterix.optimizer.rules.subplan.InlineSubplanInputForNestedTupleSourceRule.traverseNonSubplanOperator(InlineSubplanInputForNestedTupleSourceRule.java:313)
      	at org.apache.asterix.optimizer.rules.subplan.InlineSubplanInputForNestedTupleSourceRule.rewriteSubplanOperator(InlineSubplanInputForNestedTupleSourceRule.java:280)
      	at org.apache.asterix.optimizer.rules.subplan.InlineSubplanInputForNestedTupleSourceRule.rewritePre(InlineSubplanInputForNestedTupleSourceRule.java:270)
      	at org.apache.hyracks.algebricks.core.rewriter.base.AbstractRuleController.rewriteOperatorRef(AbstractRuleController.java:90)
      	at org.apache.hyracks.algebricks.compiler.rewriter.rulecontrollers.SequentialFixpointRuleController.rewriteWithRuleCollection(SequentialFixpointRuleController.java:53)
      	at org.apache.hyracks.algebricks.core.rewriter.base.HeuristicOptimizer.runOptimizationSets(HeuristicOptimizer.java:95)
      	at org.apache.hyracks.algebricks.core.rewriter.base.HeuristicOptimizer.optimize(HeuristicOptimizer.java:82)
      	at org.apache.hyracks.algebricks.compiler.api.HeuristicCompilerFactoryBuilder$1$1.optimize(HeuristicCompilerFactoryBuilder.java:87)
      	at org.apache.asterix.api.common.APIFramework.compileQuery(APIFramework.java:289)
      	at org.apache.asterix.aql.translator.QueryTranslator.rewriteCompileQuery(QueryTranslator.java:2110)
      	at org.apache.asterix.aql.translator.QueryTranslator.handleQuery(QueryTranslator.java:3015)
      	at org.apache.asterix.aql.translator.QueryTranslator.compileAndExecute(QueryTranslator.java:462)
      	at org.apache.asterix.aql.translator.QueryTranslator.compileAndExecute(QueryTranslator.java:286)
      	at org.apache.asterix.api.http.servlet.APIServlet.doPost(APIServlet.java:148)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
      	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:546)
      	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:483)
      	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:228)
      	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:956)
      	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:411)
      	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:188)
      	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:891)
      	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
      	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:114)
      	at org.eclipse.jetty.server.Server.handle(Server.java:353)
      	at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:598)
      	at org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:1076)
      	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:805)
      	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:218)
      	at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:427)
      	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:510)
      	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.access$000(SelectChannelEndPoint.java:34)
      	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:40)
      	at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:450)
      	at java.lang.Thread.run(Thread.java:745)
      

        Attachments

          Activity

            People

            • Assignee:
              buyingyi Yingyi Bu
              Reporter:
              sjaco002 Steven Jacobs
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: