Hive错误-->由于lateral view explode() 导致的空指针错误 FAILED: NullPointerException null

错误:

 代码:

select videoId,category
    from gulivideo_orc
    where videoId in (

                 select relatedId_name
                 from (
                          select relatedId, `views`
                          from gulivideo_orc
                          order by `views` desc
                          limit 50
                      ) t1--找到top50
                lateral view explode(relatedId) tmp as relatedId_name
            ) t2 --找出top50对应的相关视频Id           

 原因:经过多种测试发现是因为lateral view explode() 函数导致的,

解决方法:通过子查询再进行一次封装即可

select videoId,category
from gulivideo_orc
where videoId in (
    select *
    from (
             select relatedId_name
             from (
                      select relatedId, `views`
                      from gulivideo_orc
                      order by `views` desc
                      limit 50
                  ) t1--找到top50
            lateral view explode(relatedId) tmp as relatedId_name
         ) t2 --找出top50对应的相关视频Id
            )

 Hive错误-->由于lateral view explode() 导致的空指针错误 FAILED: NullPointerException null_第1张图片

 

你可能感兴趣的:(Hive开发总结,hive,hql,sql,数据仓库,exception)