I created two tables from java code tableHiveCell
and tableHiveWiFi
.
When I try to run followed sql command:
select count(UEs.cnc) as 'Active UEs'
^
from
(select distinct cnc from tableHiveCell wifi
union
select distinct cnc from tableHiveCell cell)
as UEs;
I get an error:
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).
Did I miss something?
[EDIT 1]
I tried:
select count(UEs.cnc) as 'Active UEs'
^
from
(select distinct cnc from tableHiveCell wifi)
union
(select distinct cnc from tableHiveCell cell)
as UEs;
Same error
[EDIT 2]
I tried:
select count(UEs.cnc) as Active_UEs
from (select distinct cnc from tableHiveCell wifi
union ALL
select distinct cnc from tableHiveCell cell) as UEs;
^
Get the same error but last as
:
line 1:142 mismatched input 'as' expecting Identifier near ')' in subquery source
As requested in Answer form:
Hadoop seems to have problems with aliases via AS
keyword on subqueries and you can easily assign the alias without the AS
Keyword.
Example can be found here: https://www.inkling.com/read/hadoop-definitive-guide-tom-white-3rd/chapter-12/querying-data
And quoted for future visitors ( see mt
alias for subquery ):
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With