I am running a query on Hive similar to:
SELECT *
FROM (SELECT a
FROM b
WHERE
sex = 'M'
AND degree = 'Bs'
AND age = 15
AND name LIKE 'L%'
);
the error is:
cannot recognize input near '<EOF>' '<EOF>' '<EOF>' in subquery source
Hive supports subqueries only in the FROM clause (through Hive 0.12). The subquery has to be given a name because every table in a FROM clause must have a name. Columns in the subquery select list must have unique names.
Hive supports subqueries in FROM clauses and in WHERE clauses of SQL statements. A subquery is a SQL expression that is evaluated and returns a result set. Then that result set is used to evaluate the parent query. The parent query is the outer query that contains the child subquery.
Hive doesn't support nested subqueries.
Adding a table alias for your subquery is necessary for Hive. Below I use 't1' as the alias:
SELECT *
FROM (SELECT a
FROM b
WHERE
sex = 'M'
AND degree = 'Bs'
AND age = 15
AND name LIKE 'L%'
) t1 ;
All the down-votes are unjustified. Hive often does not produce correct error and throws lazy "EOF" at you. In this case you just need to specify table alias for your sub-query. SELECT * FROM (.....) tbl_alias
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