Mysql ApachePhoenix中的聚合和分组依据
我试图在ApachePhoenix中执行一个查询,在这里我使用聚合和groupby函数。我在mysql中执行了相同的查询,它可以工作,但在Phoenix中,我尝试了基于mysql查询的查询,但失败了。请参见下面的mysql查询和Phoenix查询 MySQL:Mysql ApachePhoenix中的聚合和分组依据,mysql,hbase,phoenix,Mysql,Hbase,Phoenix,我试图在ApachePhoenix中执行一个查询,在这里我使用聚合和groupby函数。我在mysql中执行了相同的查询,它可以工作,但在Phoenix中,我尝试了基于mysql查询的查询,但失败了。请参见下面的mysql查询和Phoenix查询 MySQL: select id3, id4, name, descr, status, min(date) from table1 where status = "inactive" group by id3, id4, name, descr, s
select id3, id4, name, descr, status, min(date) from table1
where status = "inactive" group by id3, id4, name, descr, status
结果:id3 id4名称描述状态最小值(日期) 17773 8001300701101名称1描述20121202 17785 91000001161822名称3说明非活动20121201 凤凰查询:
select id3, id4, name, descr, status, min(date) from table1
where status = "inactive" group by id3, id4, name, descr, status
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
您可能希望签入列命名 所有表、列族和列名都是大写的,除非它们是双引号,在双引号中它们区分大小写
为什么要命名它的名称,或者在它的背面打勾,尽量不要使用保留字,以防被远程删除related@DrewPierce确定我将获取并更新表中的列名。我的问题仍然存在,即使我使用了不同的列名。另外,在执行聚合查询之前,为什么不运行一个简单的select来将所有列投影到结果集中呢。通过这种方式,您可以澄清列名是否有效。