1

集計とグループ化関数を使用している Apache Phoenix でクエリを実行しようとしています。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, status  

結果:
id3 id4 name descr status min(日付)

17773 8001300701101 name1 descr1 非アクティブ 20121202
17785 9100000161822 name3 descr3 非アクティブ 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
4

1 に答える 1