我创建了从Java代码两个表tableHiveCell
和tableHiveWiFi
.
当我尝试运行以下sql命令时:
select count(UEs.cnc) as 'Active UEs'
^
from
(select distinct cnc from tableHiveCell wifi
union
select distinct cnc from tableHiveCell cell)
as UEs;
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:
java.sql.SQLException:
Query returned non-zero code: 11,
cause: FAILED: Parse Error: line 1:22 mismatched input 'as' expecting FROM near ')' in from clause
at org.apache.hadoop.hive.jdbc.HiveStatement.executeQuery(HiveStatement.java:189).
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
[编辑1]
我试过了:
select count(UEs.cnc) as 'Active UEs'
^
from
(select distinct cnc from tableHiveCell wifi)
union
(select distinct cnc from tableHiveCell cell)
as UEs;
Run Code Online (Sandbox Code Playgroud)
同样的错误
[编辑2]
我试过了:
select count(UEs.cnc) as Active_UEs
from (select distinct cnc from tableHiveCell wifi
union ALL
select distinct cnc from tableHiveCell cell) as UEs;
^
Run Code Online (Sandbox Code Playgroud)
得到相同的错误但最后as
:
line 1:142 mismatched input 'as' expecting Identifier near ')' in subquery source
Run Code Online (Sandbox Code Playgroud)
根据答案形式的要求:Hadoop似乎AS
在子查询上通过关键字存在别名问题,您可以轻松地在没有AS
关键字的情况下分配别名.
示例可以在这里找到:https://www.inkling.com/read/hadoop-definitive-guide-tom-white-3rd/chapter-12/querying-data
并引用未来的访问者(请参阅mt
子查询的别名):
SELECT station, year, AVG(max_temperature)
FROM (
SELECT station, year, MAX(temperature) AS max_temperature
FROM records2
WHERE temperature != 9999
AND (quality = 0 OR quality = 1 OR quality = 4 OR quality = 5 OR quality = 9)
GROUP BY station, year
) mt
GROUP BY station, year;
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
49359 次 |
最近记录: |