Hive查询无法按预期工作

时间:2016-07-29 06:20:19

标签: sql hive logic hiveql mysql-logic

id                      bigint                  from deserializer   
created_at              string                  from deserializer   
source                  string                  from deserializer   
favorited               boolean                 from deserializer   
retweeted_status        struct<text:string,user:struct<screen_name:string,name:string>,retweet_count:int>   from deserializer   
entities                struct<urls:array<struct<expanded_url:string>>,user_mentions:array<struct<screen_name:string,name:string>>,hashtags:array<struct<text:string>>> from deserializer   
text                    string                  from deserializer   
user                    struct<screen_name:string,name:string,friends_count:int,followers_count:int,statuses_count:int,verified:boolean,utc_offset:int,time_zone:string,location:string>    from deserializer   
in_reply_to_screen_name string                  from deserializer   

select  id from election order by election.retweeted_status.retweet_count desc  limit 10

此查询无效 错误是“SemanticException [错误10002]:行1:53无效的列引用'retweeted_status'”

 select  * from election order by election.retweeted_status.retweet_count desc  limit 10

但是这个查询正在运行

1 个答案:

答案 0 :(得分:0)

查询按以下顺序执行

1 FROM子句

2 WHERE子句

3 GROUP BY子句

4 HAVING子句

5 SELECT子句

6 ORDER BY子句

7限制

当我们从select子句获得结果集后执行顺序,因为你没有选择select子句中的列orderby子句将无法找到列引用来执行操作。