This question is related to the answer of my previous question. Please notice that datetime
is string. Therefore I convert it to unix timestamp.
I execute this query in Hive 1.2.1:
select count(*) / count(distinct to_date(datetime)) as trips_per_day
from (select radar_id,to_unix_timestamp(datetime),lead(radar_id) over w as
next_radar_id,lead(to_unix_timestamp(datetime)) over w as
next_datetime
from mytable
where radar_id in ('A21','B15') window w as
(partition by car_id order by to_unix_timestamp(datetime))) t
where radar_id = 'A21' and next_radar_id = 'B15'
and to_unix_timestamp(datetime) + 30*60 > to_unix_timestamp(next_datetime);
But I get the following error:
SemanticException [Error 10004]: Line 11:18 Invalid table alias or column reference 'datetime': (possible column names are: radar_id, _c1, next_radar_id, next_datetime)
Where is an error?