简体   繁体   English

ALTER TABLE(配置单元)中的动态数据

[英]Dynamic Data in ALTER TABLE (Hive)

I'm getting an error with my query and I'm not entirely sure why: 我的查询出现错误,我也不完全清楚为什么:

ALTER TABLE revenue ADD PARTITION (ds=from_unixtime(unix_timestamp(), 'yyyy-MM-dd')) LOCATION CONCAT('s3://userenroll-analytics/prod/revenue/avro/', from_unixtime(unix_timestamp(), 'yyyy/MM/dd'))

Error: 错误:

Error while compiling statement: FAILED: ParseException line 1:38 cannot recognize input near 'from_unixtime' '(' 'unix_timestamp' in constant

Is there a way to use a dynamically generated value in a Hive ALTER TABLE query? 有没有办法在Hive ALTER TABLE查询中使用动态生成的值?

(PS - For those of you who say I should use dynamic partitions... I don't want to use the directory structure syntax mandated by Hive.) (PS-对于那些说我应该使用动态分区的人……我不想使用Hive强制使用的目录结构语法。)

when you use dynamic partitions for all partition fields you need to ensure that you are using nonstrict for your dynamic partition mode (hive.exec.dynamic.partition.mode) 当对所有分区字段使用动态分区时,需要确保对动态分区模式使用非严格(hive.exec.dynamic.partition.mode)

use below command before your query. 在查询之前使用以下命令。

SET hive.exec.dynamic.partition.mode=nonstrict; 设置hive.exec.dynamic.partition.mode = nonstrict;

Run following statement before alter table statment. 在alter table语句之前运行以下语句。

MSCK REPAIR TABLE revenue;

This statement will adds metadata about the partitions to the Hive catalogs. 该语句会将有关分区的元数据添加到Hive目录中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM