见下面的查询:
SELECT session_date, 'min' as stats, mini as value, product, endpoint
from
(select
distinct TO_DATE(joinstart_ev_timestamp) as session_date,
percentile_approx(cast(join_time as double),0.02) over (partition by
TO_DATE(joinstart_ev_timestamp))/1000 as mini,
percentile_approx(cast(join_time as double),0.25) over (partition by
TO_DATE(joinstart_ev_timestamp))/1000 as first_quartile,
percentile_approx(cast(join_time as double),0.50) over (partition by
TO_DATE(joinstart_ev_timestamp))/1000 as jt,
percentile_approx(cast(join_time as double),0.75) over (partition by
TO_DATE(joinstart_ev_timestamp))/1000 as third_quartile,
percentile_approx(cast(join_time as double),0.98) over (partition by
TO_DATE(joinstart_ev_timestamp))/1000 as maxi,
product_name as product,
endpoint as endpoint
from datawarehouse.join_session_fact
where
TO_DATE(joinstart_ev_timestamp) between
date_add(TO_DATE(from_unixtime(unix_timestamp())),-16) and
date_add(TO_DATE(from_unixtime(unix_timestamp())),-1)
and lower(product_name) LIKE 'gotowebinar%'
and join_time>0 and join_time <= 600000 and join_time is not null
and audio_connect_time >= 0
and (entrypoint_access_time >= 0 or entrypoint_access_time is null)
and (panel_connect_time >= 0 or panel_connect_time is null) and version =
'V2' and cast( concat( substr(data_input_date,1,4),'-'
,substr(data_input_date,5,2),'-',substr(data_input_date,7,2) ) as date)
between date_add(current_date(),-16) and date_add(current_date(),-1))
这里,子查询工作正常。但是,当我在Hive中执行完整查询时,我得到以下错误:
Error while compiling statement: FAILED: ParseException line 19:271 cannot recognize input near '<EOF>' '<EOF>' '<EOF>' in subquery source
我不明白为什么会出现这个错误? (括号看起来很好)
答案 0 :(得分:0)
我在这个子查询中发现了问题。它最终需要一个表别名。由于某种方式中的子查询也是临时表,因此需要对其进行命名。
例如,在查询末尾添加别名“t”,它将起作用。
SELECT session_date, 'min' as stats, mini as value, product, endpoint
from
(select
distinct TO_DATE(joinstart_ev_timestamp) as session_date,
..and so on..
between date_add(current_date(),-16) and date_add(current_date(),-1)) t;