运行sql查询Hadoop Java时,在FROM子句中获取错误“输入不匹配”为“预期来自附近”)
我用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;
我得到一个错误:
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).
我错过什么了吗
[编辑1]
我试过:
select count(UEs.cnc) as 'Active UEs'
^
from
(select distinct cnc from tableHiveCell wifi)
union
(select distinct cnc from tableHiveCell cell)
as UEs;
同样的错误
[编辑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;
^
获取相同的错误,但最后as
:
line 1:142 mismatched input 'as' expecting Identifier near ')' in subquery source
# 1 楼答案
按照答题表的要求: Hadoop似乎在子查询中通过
AS
关键字使用别名时遇到问题,您可以轻松地分配别名,而无需AS
关键字例如:https://www.inkling.com/read/hadoop-definitive-guide-tom-white-3rd/chapter-12/querying-data
并为未来的访客报价(子查询请参见
mt
别名):