例外 - 在HiveQL中组合两个数据集

时间:2016-04-12 12:57:31

标签: sql exception hiveql

我正在面对Analytics Exception,同时要将内部数据集合并。

查询

Select key,days
    FROM
    (
        Select key          
        FROM sls where id =14004
    ) AS first
    JOIN 
    (
        Select seckey ,days
        FROM
        (
            Select seckey , MAX(opp_days) As days from sls_daily Where id=14004 Group By key
        ) As f
        JOIN
        (
            Select  key,est,cls,days from sls_daily Where dw_cid=14004
        ) As s
        ON f.days = s.days  AND  f.key= s.key
    ) AS second
    ON second.seckey = first.key 

异常

  

AnalysisException:第15行中的语法错误:)AS first ^遇到:   FIRST预期:IDENTIFIER CAUSED BY:异常:语法错误

错误的原因是什么。

1 个答案:

答案 0 :(得分:2)

尽量避免reserved中的SQL字。

试试这个

Select `key`,`days`
    FROM
    (
        Select `key`         
        FROM sls where id =14004
    ) AS `first`
    JOIN 
    (
        Select seckey ,`days`
        FROM
        (
            Select seckey , MAX(opp_days) As `days` from sls_daily Where id=14004 Group By key
        ) As f
        JOIN
        (
            Select  `key`,est,cls,`days` from sls_daily Where dw_cid=14004
        ) As s
        ON f.`days` = s.`days`  AND  f.`key`= s.`key`
    ) AS `second`
    ON `second`.seckey = `first`.`key`