在databricks中运行此查询时出错。如何将以下sql查询转换为hivesql:
%sql
-- To clear table if it already exists
DROP TABLE IF EXISTS air_d;
-- Create temp table syntax
CREATE TEMP VIEW air_d AS
select *,airport_1+'-'+airport_2 as route,cast(citymarketid_1 as varchar)+cast(citymarketid_2 as varchar) as city_route
from
(select year, quarter, tkcarrier, nonstopmiles, OriginCityMarketID, DestCityMarketID, Origin, Dest, passengers, mktfare, itingeotype, bulkfare, mktmilesflown, #car_airlineid.car_flag, car_airlineid.airlineid,
case when t1.citymarketnmesrt < t2.citymarketnmesrt then origin else dest end as airport_1,
case when t1.citymarketnmesrt < t2.citymarketnmesrt then dest else origin end as airport_2,
case when t1.citymarketnmesrt < t2.citymarketnmesrt then origincitymarketid else destcitymarketid end as citymarketid_1,
case when t1.citymarketnmesrt < t2.citymarketnmesrt then destcitymarketid else origincitymarketid end as citymarketid_2
from air_db
LEFT OUTER JOIN aptcty as t1 on air_db.originairportid=t1.airportid
LEFT OUTER JOIN aptcty as t2 on air_db.destairportid=t2.airportid
LEFT OUTER JOIN #car_airlineid on air_db.tkcarrierairlineid=#car_airlineid.airlineid
where (Year>=2003 and Year<=2018) or (Year=2019 and Quarter in (1,2)) and OriginCountry = 'US' and DestCountry = 'US') as new_table;
这是错误:
sql语句中出错:parseexception:应为不匹配的输入“from”(第4行,位置0)
1条答案
按热度按时间wvt8vs2t1#
答案如下: