shamim8888 / asterixdb

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

Join using function returning null[] #837

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
DDL:
drop dataverse channels if exists;
create dataverse channels;
use dataverse channels;

create type TweetMessageType as closed {
  tweetid: int64,
  sender-location: point
}

create type TweetHistorySubscription as open{
  subscription-id: int32,
  location: point
}

create dataset TweetHistorySubscriptions(TweetHistorySubscription)
primary key subscription-id;
create index testa on TweetHistorySubscriptions(location) type rtree;

create dataset TweetMessages(TweetMessageType)
primary key tweetid;
create index locationIdx on TweetMessages(sender-location) type rtree;

create function NearbyTweetsContainingText($location) {
  for $tweet in dataset TweetMessages
    let $circle := create-circle($location,30.0)
    where spatial-intersect($tweet.sender-location, $circle)
    return $tweet
};

for $sub in dataset TweetHistorySubscriptions
for $tweet in NearbyTweetsContainingText($sub.location)
return {
"tweet":$tweet
}

The query returns null[] to the user. As far as I know, this should be a 
legitimate query.

Original issue reported on code.google.com by sjaco...@ucr.edu on 8 Dec 2014 at 8:28

GoogleCodeExporter commented 9 years ago
Here's the relevant stack trace:

java.lang.NullPointerException
    at edu.uci.ics.asterix.optimizer.rules.am.OptimizableFuncExpr.getConstantVal(OptimizableFuncExpr.java:100)
    at edu.uci.ics.asterix.optimizer.rules.am.AccessMethodUtils.createSearchKeyExpr(AccessMethodUtils.java:297)
    at edu.uci.ics.asterix.optimizer.rules.am.RTreeAccessMethod.createSecondaryToPrimaryPlan(RTreeAccessMethod.java:245)
    at edu.uci.ics.asterix.optimizer.rules.am.RTreeAccessMethod.applySelectPlanTransformation(RTreeAccessMethod.java:156)
    at edu.uci.ics.asterix.optimizer.rules.am.IntroduceSelectAccessMethodRule.rewritePost(IntroduceSelectAccessMethodRule.java:113)
    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:108)
    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.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:91)
    at edu.uci.ics.hyracks.algebricks.core.rewriter.base.HeuristicOptimizer.optimize(HeuristicOptimizer.java:78)
    at edu.uci.ics.hyracks.algebricks.compiler.api.HeuristicCompilerFactoryBuilder$1$1.optimize(HeuristicCompilerFactoryBuilder.java:83)
    at edu.uci.ics.asterix.api.common.APIFramework.compileQuery(APIFramework.java:308)
    at edu.uci.ics.asterix.aql.translator.AqlTranslator.rewriteCompileQuery(AqlTranslator.java:1722)
    at edu.uci.ics.asterix.aql.translator.AqlTranslator.handleQuery(AqlTranslator.java:2034)
    at edu.uci.ics.asterix.aql.translator.AqlTranslator.compileAndExecute(AqlTranslator.java:315)
    at edu.uci.ics.asterix.api.http.servlet.APIServlet.doPost(APIServlet.java:97)

Original comment by sjaco...@ucr.edu on 8 Dec 2014 at 10:04

GoogleCodeExporter commented 9 years ago
The simple description of the issue here is that the optimizer treats the 
spatial-intersect as if it is being used for a selection rather than for a join.

Original comment by sjaco...@ucr.edu on 8 Dec 2014 at 10:17

GoogleCodeExporter commented 9 years ago
You should also try the query which is inside the AQL function (which is inside 
create function... body) in your query. Meaning replace the call to the 
function NearbyTweetsContainingText($sub.location) with the actual query that 
is inside the function body. If that works we can eliminate the function part. 

If it also fails w/o the function, then the problem is not specific to the 
create function.

Original comment by khfaraaz82 on 8 Dec 2014 at 10:28

GoogleCodeExporter commented 9 years ago
I have already tried it this way, It works correctly (and incidentally it uses 
the index)

Original comment by sjaco...@ucr.edu on 8 Dec 2014 at 10:36

GoogleCodeExporter commented 9 years ago
Ok, I see so the NPE is seen only when you define the function, and the 
function has the AQL query in its definition.

Original comment by khfaraaz82 on 8 Dec 2014 at 10:42

GoogleCodeExporter commented 9 years ago
Exactly.

Original comment by sjaco...@ucr.edu on 8 Dec 2014 at 10:47

GoogleCodeExporter commented 9 years ago

Original comment by sjaco...@ucr.edu on 15 Dec 2014 at 7:06

GoogleCodeExporter commented 9 years ago
This bug was actually caused by the problem in issue838

Original comment by sjaco...@ucr.edu on 17 Dec 2014 at 9:59