How can I convert the following query to be compatible with Spark 1.6 which does not supported subqueries:
SELECT ne.device_id, sp.device_hostname
FROM `table1` ne INNER JOIN `table2` sp
ON sp.device_hostname =
(SELECT device_hostname FROM `table2`
WHERE device_hostname LIKE
CONCAT(ne.device_id,'%') ORDER BY device_hostname DESC LIMIT 1)
I have read that it supports subqueries specified in the FROM but not WHERE but the following also doesn't work:
SELECT * FROM (SELECT ne.device_id, sp.device_hostname
FROM `table1` ne INNER JOIN `table2` sp
ON sp.device_hostname =
(SELECT device_hostname FROM `table2`
WHERE device_hostname LIKE
CONCAT(ne.device_id,'%') ORDER BY device_hostname DESC LIMIT 1)) AS TA
My overall goal is to join two tables though only get the last record from table2. The SQL statements are valid though when I use them within a HiveContext.sql within Spark I get an Analysis Exception.