Hive查询报错 Invalid table alias or column reference 'create_time': (possible column names are: _c0, _c1
2016-10-11 18:55
1911 查看
在执行Hive操作的时候有时候会遇到这种报错:
Invalid table alias or column reference 'create_time': (possible column names are: _c0, _c1, _c2, _c3)
下面来分析这个条Hive语句:
select to_date(create_time) as time, count(*) as allNum, count(if(source=3,1,NULL)) as iosNum, count(if(source=4,1,NULL)) as androidNum
from dg_cook
where to_date(create_time)>='2016-08-10' and to_date(create_time)<='2016-10-10'
group by to_date(create_time)
order by to_date(create_time)
limit 1000
事实上Hive在执行完成group by之后其实已经默认吧以上所有的语句当成了一条,也就是说:
select to_date(create_time) as time, count(*) as allNum, count(if(source=3,1,NULL)) as iosNum, count(if(source=4,1,NULL)) as androidNum
from dg_cook
where to_date(create_time)>='2016-08-10' and to_date(create_time)<='2016-10-10'
group by to_date(create_time)
到最后执行完成,Hive把它当成一个语句,最后在order by to_date(create_time)时,Hive就不会识别到底啥是to_date(create_time)
解决方案:
select to_date(create_time) as time, count(*) as allNum, count(if(source=3,1,NULL)) as iosNum, count(if(source=4,1,NULL)) as androidNum
from dg_cook
where to_date(create_time)>='2016-08-10' and to_date(create_time)<='2016-10-10'
group by to_date(create_time)
order by time
limit 1000
order by的时候使用别名,就能够执行过去啦~
Invalid table alias or column reference 'create_time': (possible column names are: _c0, _c1, _c2, _c3)
下面来分析这个条Hive语句:
select to_date(create_time) as time, count(*) as allNum, count(if(source=3,1,NULL)) as iosNum, count(if(source=4,1,NULL)) as androidNum
from dg_cook
where to_date(create_time)>='2016-08-10' and to_date(create_time)<='2016-10-10'
group by to_date(create_time)
order by to_date(create_time)
limit 1000
事实上Hive在执行完成group by之后其实已经默认吧以上所有的语句当成了一条,也就是说:
select to_date(create_time) as time, count(*) as allNum, count(if(source=3,1,NULL)) as iosNum, count(if(source=4,1,NULL)) as androidNum
from dg_cook
where to_date(create_time)>='2016-08-10' and to_date(create_time)<='2016-10-10'
group by to_date(create_time)
到最后执行完成,Hive把它当成一个语句,最后在order by to_date(create_time)时,Hive就不会识别到底啥是to_date(create_time)
解决方案:
select to_date(create_time) as time, count(*) as allNum, count(if(source=3,1,NULL)) as iosNum, count(if(source=4,1,NULL)) as androidNum
from dg_cook
where to_date(create_time)>='2016-08-10' and to_date(create_time)<='2016-10-10'
group by to_date(create_time)
order by time
limit 1000
order by的时候使用别名,就能够执行过去啦~
相关文章推荐
- org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or br
- Django(博客系统):按照时间分层筛选“/blog/article/?create_time__year=2017”,出现问题:Database returned an invalid datetime value. Are time zone definitions for your database installed?
- SQL Server Error Messages - Msg 1776 : There are no primary or candidate keys in the referenced Table
- ORA-01747: invalid user.table.column, table.column, or column specification
- 解决异常-ORA-01747 invalid user.table.column, table.column, or column specification
- 异常-ORA-01747: invalid user.table.column, table.column, or column specification
- Oracle ORA-01747: invalid user.table.column, table.column, or column specification
- 解决异常-ORA-01747 invalid user.table.column, table.column, or column specification
- Possible causes are invalid address of the remote server or browser start-up failure.
- one or more table pointers are invalid【解决方法】
- 添加外键出现There are no primary or candidate keys in the referenced table ×××××的错误
- 20120606:ORA-01747: invalid user.table.column, table.column, or column specification
- how to create pooled table or cluster table
- How to Create Transportable Tablespaces Where the Source and Destination are ASM-Based
- the create feature task could not be completed,the coordinates or measures are out of bounds
- Logon failure: user account restriction. Possible reasons are blank passwords not allowed, logon hour restrictions, or a policy
- freemarker.core.InvalidReferenceException: Expression parameters.parseContent is undefined on line 45, column 28 in template/aja
- Compiler Error Message: CS0234: The type or namespace name ''(are you missing an assembly reference?)
- .net4 wpf App 使用log4net 错误:The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly reference?)
- Create a program the checks all the links in your web page whether they are active or not.