I have used the below query on Hive and got the following parse error though the query does not seem to have any issues.
SELECT TO_DATE(o.order_date), profit,
ROW_NUMBER() OVER (PARTITION BY YEAR(o.order_date) ORDER BY profit desc) AS n
FROM (
SELECT TO_DATE(o.order_date), SUM(price) AS revenue,
SUM(price-cost) as profit
FROM products p, order_details d, orders o
WHERE (d.prod_id=p.prod_id) AND (d.order_id=o.order_id)
GROUP BY o.order_date
)
Error is:
error while compiling statement: failed: parseexception line 6:22 cannot recognize input near '' '' '' in subquery source
Well just to mention. You use in your SELECT some aliases like
o.order_date)
in yourTO_DATE
and insider yourOVER
-clause. But yourFROM
part is just a query in braces without an given alias after the closing brace)
.I would expect
) as o
instead.