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沒有改變,直到選票達到一定的門檻?再次感謝! –