Apache Phoenix中的聚合和分组

时间:2015-06-13 15:48:45

标签: mysql hbase phoenix

我正在尝试在Apache Phoenix中执行查询,我在使用aggregate和groupby函数。我已经在mysql中执行了相同的查询,它可以工作,但在凤凰城我尝试了基于mysql查询的查询,但它失败了。请参阅下面的mysql查询和Phoenix查询。

MySQL:

select id3, id4, name, descr, status, min(date) from table1
where status = "inactive" group by id3, id4, name, descr, status  

结果:
id3 id4 name descr status min(date)

17773 8001300701101 name1 descr1 INACTIVE 20121202
17785 9100000161822 name3 descr3 INACTIVE 20121201

凤凰查询:

MySQL和Phoenix之间的查询没有区别。

select id3, id4, name, descr, status, min ( date )  from table1
WHERE status = 'inactive' group by  id3, id4, name, descr, status;  

但我得到以下错误可以解释一下吗?

Error: ERROR 1018 (42Y27): Aggregate may not contain columns not in GROUP BY. ELS_NAME (state=42Y27,code=1018)
java.sql.SQLException: ERROR 1018 (42Y27): Aggregate may not contain columns not in GROUP BY. ELS_NAME
    at org.apache.phoenix.exception.SQLExceptionCode$Factory$1.newException(SQLExceptionCode.java:361)
    at org.apache.phoenix.exception.SQLExceptionInfo.buildException(SQLExceptionInfo.java:133)
    at org.apache.phoenix.compile.ExpressionCompiler.throwNonAggExpressionInAggException(ExpressionCompiler.java:1141)
    at org.apache.phoenix.compile.ProjectionCompiler.compile(ProjectionCompiler.java:378)
    at org.apache.phoenix.compile.QueryCompiler.compileSingleFlatQuery(QueryCompiler.java:490)
    at org.apache.phoenix.compile.QueryCompiler.compileSingleQuery(QueryCompiler.java:447)
    at org.apache.phoenix.compile.QueryCompiler.compile(QueryCompiler.java:154)
    at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:331)
    at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:314)
    at org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:230)
    at org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:226)
    at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
    at org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:225)
    at org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1066)
    at sqlline.Commands.execute(Commands.java:822)
    at sqlline.Commands.sql(Commands.java:732)
    at sqlline.SqlLine.dispatch(SqlLine.java:808)
    at sqlline.SqlLine.begin(SqlLine.java:681)
    at sqlline.SqlLine.start(SqlLine.java:398)
    at sqlline.SqlLine.main(SqlLine.java:292

1 个答案:

答案 0 :(得分:2)

您可能需要检查列命名。

  

所有表格,列系列和列名称都是大写的,除非它们是双引号,在这种情况下它们区分大小写。

https://phoenix.apache.org/language/index.html