0
第一个查询正常。但第二个查询发出错误“[Error 10025]表达式不在GROUP BY键'-3''”中。我阅读了相关文章,到目前为止我不确定如何解决这个错误。Hive [错误10025]表达式不在GROUP BY中
非常感谢您对此的帮助。
查询#1
SELECT case when user_id = '-3' then cast(order_id as varchar(255)) else user_id end as user_id2
from orders
where user_id = '-3'
查询#2
SELECT case when user_id = '-3' then cast(order_id as varchar(255)) else user_id end as user_id2
,sum(order_value) as sales
from orders
group by 1
Traceback (most recent call last):
File "/home/net1/liulu001/conversant/troubleshooting_userid.py", line 28, in <module>
cursor.execute(q)
File "/home/net1/liulu001/.local/lib/python2.6/site-packages/impala/hiveserver2.py", line 302, in execute
configuration=configuration)
File "/home/net1/liulu001/.local/lib/python2.6/site-packages/impala/hiveserver2.py", line 343, in execute_async
self._execute_async(op)
File "/home/net1/liulu001/.local/lib/python2.6/site-packages/impala/hiveserver2.py", line 362, in _execute_async
operation_fn()
File "/home/net1/liulu001/.local/lib/python2.6/site-packages/impala/hiveserver2.py", line 340, in op
async=True)
File "/home/net1/liulu001/.local/lib/python2.6/site-packages/impala/hiveserver2.py", line 1027, in execute
return self._operation('ExecuteStatement', req)
File "/home/net1/liulu001/.local/lib/python2.6/site-packages/impala/hiveserver2.py", line 957, in _operation
resp = self._rpc(kind, request)
File "/home/net1/liulu001/.local/lib/python2.6/site-packages/impala/hiveserver2.py", line 925, in _rpc
err_if_rpc_not_ok(response)
File "/home/net1/liulu001/.local/lib/python2.6/site-packages/impala/hiveserver2.py", line 704, in err_if_rpc_not_ok
raise HiveServer2Error(resp.status.errorMessage)
impala.error.HiveServer2Error: Error while compiling statement: FAILED: SemanticException [Error 10025]: Line 3:13 Expression not in GROUP BY key ''-3''
谢谢。我想我已经尝试了使用你所建议的语法的组,并得到类似的错误。但我只是试了一遍,它运行良好。所以问题解决了。再次感谢! –
那么,你对我的回答满意吗?那么请投票或接受或建议我怎样才能改善答案。 – leftjoin
是的,满意答案。刚刚投票有用。我猜这个0没有改变,直到选票达到一定的门槛?再次感谢! –