lwhay / asterixdb

Automatically exported from code.google.com/p/asterixdb
0 stars 0 forks source link

NPE Exception - using three "for" loops #740

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Reproduction:
===============
1. Define three lets each containing a list. 
2. Iterate on each of them in parallel using three "for" calls as showed below

Expectation: 
=============
You get an NPE instead of an iteration over the lists.
Note that if you reduce the number of "for" to two - it works (with any of the 
for).

*the purpose of this query is to group-by and then on each of the internal 
items matching the group-key make a distinct and an aggregation. I removed from 
the example below the aggregation to make the reproduction simpler.

insert into dataset tmp(
for $t in dataset page_views
group by $t.user with $t
return {
"groups": $t
}
);

//for $i in dataset tmp 
//return $i

let $beth :=
for $i in dataset tmp 
let $groups := $i.groups
for $item in $groups
distinct by $item.user, $item.action
return {
"user": $item.user,
"action": $item.action
}

let $rev :=
for $i in dataset tmp 
let $groups := $i.groups
for $item in $groups
distinct by $item.user, $item.estimated_revenue
return {
"user": $item.user,
"est": $item.estimated_revenue
}

let $ts :=
for $i in dataset tmp 
let $groups := $i.groups
for $item in $groups
distinct by $item.user, $item.timespent
return {
"user": $item.user,
"timespent": $item.timespent
}
for $a in $beth
for $b in $rev
for $c in $ts //<== without this "for" (*OR* the "for above) the query works 
return $a

Original issue reported on code.google.com by ker...@gmail.com on 20 Mar 2014 at 7:58

GoogleCodeExporter commented 9 years ago
Note that the emssage you get in the output page is null[] and the stack trace 
is:
SEVERE: null
java.lang.NullPointerException
    at edu.uci.ics.asterix.om.typecomputer.impl.NonTaggedCollectionMemberResultType.computeType(NonTaggedCollectionMemberResultType.java:42)
    at edu.uci.ics.asterix.dataflow.data.common.AqlExpressionTypeComputer.getTypeForFunction(AqlExpressionTypeComputer.java:88)
    at edu.uci.ics.asterix.dataflow.data.common.AqlExpressionTypeComputer.getType(AqlExpressionTypeComputer.java:56)
    at edu.uci.ics.hyracks.algebricks.core.algebra.typing.AbstractTypeEnvironment.getType(AbstractTypeEnvironment.java:41)
    at edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.UnnestOperator.computeOutputTypeEnvironment(UnnestOperator.java:102)
    at edu.uci.ics.hyracks.algebricks.core.rewriter.base.AlgebricksOptimizationContext.computeAndSetTypeEnvironmentForOperator(AlgebricksOptimizationContext.java:255)
    at edu.uci.ics.hyracks.algebricks.rewriter.rules.ComplexUnnestToProductRule.rewritePost(ComplexUnnestToProductRule.java:110)
    at edu.uci.ics.hyracks.algebricks.core.rewriter.base.AbstractRuleController.rewriteOperatorRef(AbstractRuleController.java:122)
    at edu.uci.ics.hyracks.algebricks.core.rewriter.base.AbstractRuleController.rewriteOperatorRef(AbstractRuleController.java:96)
    at edu.uci.ics.hyracks.algebricks.core.rewriter.base.AbstractRuleController.rewriteOperatorRef(AbstractRuleController.java:96)
    at edu.uci.ics.hyracks.algebricks.core.rewriter.base.AbstractRuleController.rewriteOperatorRef(AbstractRuleController.java:96)
    at edu.uci.ics.hyracks.algebricks.compiler.rewriter.rulecontrollers.SequentialFixpointRuleController.rewriteWithRuleCollection(SequentialFixpointRuleController.java:49)
    at edu.uci.ics.hyracks.algebricks.core.rewriter.base.HeuristicOptimizer.runOptimizationSets(HeuristicOptimizer.java:93)
    at edu.uci.ics.hyracks.algebricks.core.rewriter.base.HeuristicOptimizer.optimize(HeuristicOptimizer.java:80)
    at edu.uci.ics.hyracks.algebricks.compiler.api.HeuristicCompilerFactoryBuilder$1$1.optimize(HeuristicCompilerFactoryBuilder.java:81)
    at edu.uci.ics.asterix.api.common.APIFramework.compileQuery(APIFramework.java:285)
    at edu.uci.ics.asterix.aql.translator.AqlTranslator.rewriteCompileQuery(AqlTranslator.java:1428)
    at edu.uci.ics.asterix.aql.translator.AqlTranslator.handleQuery(AqlTranslator.java:1724)
    at edu.uci.ics.asterix.aql.translator.AqlTranslator.compileAndExecute(AqlTranslator.java:301)
    at edu.uci.ics.asterix.api.http.servlet.APIServlet.doPost(APIServlet.java:97)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
    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:231)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:970)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:411)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:904)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)
    at org.eclipse.jetty.server.Server.handle(Server.java:347)
    at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:439)
    at org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:924)
    at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:781)
    at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:220)
    at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:43)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:545)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:43)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:529)
    at java.lang.Thread.run(Thread.java:722)

Original comment by ker...@gmail.com on 20 Mar 2014 at 8:34

GoogleCodeExporter commented 9 years ago
Pigmix blocker. 
Query 15 would then be expressed with the above three lets followed by:
for $a in $beth
for $b in $ts
for $c in $rev
where $a.user=$b.user and $a.user=$c.user and $b.user=$c.user
return {
"user":$a.user,
"beth":count($beth),
"ts": avg(for $l in $ts return $l.timespent),
"rev":sum (for $k in $rev return $k.estimated_revenue)
}

Original comment by ker...@gmail.com on 17 Nov 2014 at 4:45