hive中执行sql语句出现数据类型问题

来源:互联网 发布:澳洲研究型硕士 知乎 编辑:程序博客网 时间:2024/05/29 11:37

当在执行Hive sql时候,用到了下面的语句:

select concat(session_id, '@@', apk_id) as sid, package_name, 1 is_install
  from table_xxx
 where report_date = '20150905'
 group by package_name, session_id, apk_id 
 having sum(case is_install when 1 then 1 when 0 then - 1 end) > 0 limit 10;

会提示报错:hive "bigint" is expected but "int" is found

原因是由于is_install字段在数据库中为bigint类型,此时要进行转换,转换很简单,直接在对应的字段加L即可

 having sum(case is_install when 1L then 1 when 0L then - 1 end) > 0 limit 10;


0 0
原创粉丝点击