SOLR并行SQL:GROUP BY抛出异常

时间:2017-10-16 11:26:27

标签: sql solr

此查询按预期工作:

SELECT sum(amount) as total FROM donation

添加GROUP BY:

SELECT sum(amount) as total FROM donation GROUP BY people_person_id

现在我得到回复:

{
  "result-set":{
    "docs":[{
        "EXCEPTION":"Failed to execute sqlQuery 'SELECT sum(amount) as total  FROM donation GROUP BY people_person_id' against JDBC connection 'jdbc:calcitesolr:'.\nError while executing SQL \"SELECT sum(amount) as total  FROM donation GROUP BY people_person_id\": null",
        "EOF":true,
        "RESPONSE_TIME":279}]}
}

people_person_id字段存在,已存储,docValues = true。

关于导致这种情况的任何想法?或者如何调试?

这是集合结构:

<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false"/>
<field name="people_person_id" type="int" indexed="true" stored="true" required="true" multiValued="false" docValues="true"/>
<field name="group_id" type="int" indexed="true" stored="false" required="true" multiValued="false"/>
<field name="amount" type="float" indexed="true" stored="true" multiValued="false" docValues="true"/>

2 个答案:

答案 0 :(得分:0)

您显示的查询与邮件中显示的查询之间存在差异。

您的查询 选择总和(金额)作为总捐赠来自GROUP BY people_person_id

消息中显示的

查询 SELECT sum(people_person_id)as total FROM GROUP GROUP group_id

您编写的查询绝对正确,但如果&#34; people_person_id&#34;则消息中显示的查询可能无法为您提供所需的结果。不是任何数字,而是一个角色。

请发布您正在运行查询的表结构

答案 1 :(得分:0)

感谢SOLR邮件列表中的Joel Bernstein。这里的问题是SQL语句不符合语法标准。查询应为:

SELECT people_person_id, sum(amount) as total FROM donation GROUP BY
people_person_id

换句话说,您正在分组的列应该出现在SELECT中。

SOLR当然应该回复一个正确的错误消息而不是'null',因为这是一个完美的MySQL查询SQL。