hive函数转换为sql函数

时间:2017-07-19 09:16:44

标签: sql oracle hive

我需要帮助将以下Hive查询转换为SQL查询。我需要知道如何将unix时间戳函数转换为SQL。

SELECT 
    person_id, supervisor_id, assignment_type, primary_flag, 
    effective_start_date, effective_end_date,
    MAX(effective_start_date) OVER (PARTITION BY p.person_id) AS max_effective_start_date
FROM 
    cg1_per_all_assignments_f p
WHERE 
    to_date(CURRENT_TIMESTAMP) >= COALESCE(to_date(from_unixtime(unix_timestamp(p.EFFECTIVE_START_DATE, 'yyyy-MM-dd'))), DATE_SUB(to_date(from_unixtime(unix_timestamp())), 1))
    AND to_date(CURRENT_TIMESTAMP) <= COALESCE(to_date(from_unixtime(unix_timestamp(p.EFFECTIVE_END_DATE, 'yyyy-MM-dd'))), DATE_ADD(to_date(from_unixtime(unix_timestamp())), 1))

1 个答案:

答案 0 :(得分:0)

使用Oracle的功能:

Hive => Oracle:

to_date(CURRENT_TIMESTAMP) => sysdate 
DATE_SUB(to_date(from_unixtime(unix_timestamp())), 1) => sysdate -1