创建分区视图时 Hive 出错

Hive error while creating partitioned view

我得到一个 'log' table,它目前按年、月和日划分。我想在 'log' table 之上创建一个分区视图,但 运行 进入此错误:

hive> CREATE VIEW log_view PARTITIONED ON (pagename,year,month,day) AS SELECT pagename, year,month,day,uid,properties FROM log; 

FAILED: SemanticException [Error 10093]: Rightmost columns in view output do not match PARTITIONED ON clause

创建分区视图的正确方法是什么?

试试这个..

 CREATE VIEW log_view PARTITIONED ON (pagename,year,month,day) AS SELECT uid,properties,pagename, year,month,day FROM log; 

原因是分区列必须位于 select 语句查询中的最后。