br1ghtyang / asterixdb

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

Need support to return max and min of strings by max/min aggregate functions #531

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Currently, we do not support aggregation of max and min of strings. This must 
be supported. The following issue was observed on Asterix version:0.8.1-SNAPSHOT

What steps will reproduce the problem?

Start AsterixDB using managix on a single node and run following AQL statements 
from Web UI.

drop dataverse tempdb if exists;
create dataverse tempdb;
use dataverse tempdb;

create type TestType as open{
id:int32,
name:string
}

create dataset t1(TestType) primary key id;

insert into dataset t1({"id":5,"name":"Smith"});
insert into dataset t1({"id":12,"name":"Roger"});
insert into dataset t1({"id":67,"name":"Kevin"});
insert into dataset t1({"id":32,"name":"Bob"});
insert into dataset t1({"id":89,"name":"John"});
insert into dataset t1({"id":10,"name":"Alex"});
insert into dataset t1({"id":37,"name":"Calvin"});
insert into dataset t1({"id":98,"name":"Susan"});

min(for $l in dataset t1
return $l.name)

Result :
Sum aggregator is not implemented for STRING [NotImplementedException]

Stack trace from cc.log

INFO: Executing: 
edu.uci.ics.hyracks.control.cc.work.JobletCleanupNotificationWork@285df6f6
edu.uci.ics.hyracks.algebricks.common.exceptions.NotImplementedException: Sum 
aggregator is not implemented for STRING
        at edu.uci.ics.asterix.om.typecomputer.impl.NonTaggedSumTypeComputer.computeType(NonTaggedSumTypeComputer.java:85)
        at edu.uci.ics.asterix.dataflow.data.common.AqlExpressionTypeComputer.getTypeForFunction(AqlExpressionTypeComputer.java:80)
        at edu.uci.ics.asterix.dataflow.data.common.AqlExpressionTypeComputer.getType(AqlExpressionTypeComputer.java:54)
        at edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AggregateOperator.computeOutputTypeEnvironment(AggregateOperator.java:102)
        at edu.uci.ics.hyracks.algebricks.core.rewriter.base.AlgebricksOptimizationContext.computeAndSetTypeEnvironmentForOperator(AlgebricksOptimizationContext.java:255)
        at edu.uci.ics.asterix.optimizer.rules.PushAggFuncIntoStandaloneAggregateRule.rewritePost(PushAggFuncIntoStandaloneAggregateRule.java:129)
        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.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:286)
        at edu.uci.ics.asterix.aql.translator.AqlTranslator.rewriteCompileQuery(AqlTranslator.java:1293)
        at edu.uci.ics.asterix.aql.translator.AqlTranslator.handleQuery(AqlTranslator.java:1387)
        at edu.uci.ics.asterix.aql.translator.AqlTranslator.compileAndExecute(AqlTranslator.java:279)
        at edu.uci.ics.asterix.api.http.servlet.APIServlet.doPost(APIServlet.java:96)
        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)
Jun 12, 2013 7:25:49 PM edu.uci.ics.asterix.api.http.servlet.APIServlet doPost
SEVERE: Sum aggregator is not implemented for STRING
edu.uci.ics.hyracks.algebricks.common.exceptions.NotImplementedException: Sum 
aggregator is not implemented for STRING
        at edu.uci.ics.asterix.om.typecomputer.impl.NonTaggedSumTypeComputer.computeType(NonTaggedSumTypeComputer.java:85)
        at edu.uci.ics.asterix.dataflow.data.common.AqlExpressionTypeComputer.getTypeForFunction(AqlExpressionTypeComputer.java:80)
        at edu.uci.ics.asterix.dataflow.data.common.AqlExpressionTypeComputer.getType(AqlExpressionTypeComputer.java:54)
        at edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AggregateOperator.computeOutputTypeEnvironment(AggregateOperator.java:102)
        at edu.uci.ics.hyracks.algebricks.core.rewriter.base.AlgebricksOptimizationContext.computeAndSetTypeEnvironmentForOperator(AlgebricksOptimizationContext.java:255)
        at edu.uci.ics.asterix.optimizer.rules.PushAggFuncIntoStandaloneAggregateRule.rewritePost(PushAggFuncIntoStandaloneAggregateRule.java:129)
        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.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:286)
        at edu.uci.ics.asterix.aql.translator.AqlTranslator.rewriteCompileQuery(AqlTranslator.java:1293)
        at edu.uci.ics.asterix.aql.translator.AqlTranslator.handleQuery(AqlTranslator.java:1387)
        at edu.uci.ics.asterix.aql.translator.AqlTranslator.compileAndExecute(AqlTranslator.java:279)
        at edu.uci.ics.asterix.api.http.servlet.APIServlet.doPost(APIServlet.java:96)
        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)
edu.uci.ics.hyracks.algebricks.common.exceptions.NotImplementedException

Original issue reported on code.google.com by khfaraaz82 on 13 Jun 2013 at 2:35

GoogleCodeExporter commented 8 years ago
@Khurram when you say "support", do you mean that we should support min/max 
over string, or we should return reasonable error message for this? If it is 
for the former, could you provide the semantics for min/max over string? 

Original comment by jarod...@gmail.com on 13 Jun 2013 at 2:52

GoogleCodeExporter commented 8 years ago
I meant the former. Since we do support comparison of strings (str1 > str2 and 
so on) in AsterixDB, getting the max/min from a set of input strings should 
also be supported by aggregate functions.

Original comment by khfaraaz82 on 13 Jun 2013 at 2:59

GoogleCodeExporter commented 8 years ago
This issue was closed by revision f1762cd6a9f2.

Original comment by jarod...@gmail.com on 28 Jun 2013 at 1:41

GoogleCodeExporter commented 8 years ago
Falsely closed by the commit message; reopen it for code review.

Original comment by jarod...@gmail.com on 28 Jun 2013 at 1:47

GoogleCodeExporter commented 8 years ago
The fix (f1762cd) has been merged into master.

Original comment by jarod...@gmail.com on 15 Nov 2013 at 5:52