我有一个hive脚本,可以将数据从dynamo-db导出到s3 我试图将日期放到动态创建的s3文件夹的位置 最有可能的是我需要蜂巢的内置功能。 我在网上搜索了很多例子 (String dt) - >并手动给出日期,但我应该自动输入。
修改
应该是这样的,但我有错误,这是我目前的蜂巢脚本:
CREATE EXTERNAL TABLE IF NOT EXISTS tracksTable (id bigint, json binary)
STORED BY 'org.apache.hadoop.hive.dynamodb.DynamoDBStorageHandler'
TBLPROPERTIES ("dynamodb.table.name" = "tablename",
"dynamodb.column.mapping" = "id:id,json:json");
SET hive.exec.dynamic.partition.mode=nonstrict;
CREATE EXTERNAL TABLE IF NOT EXISTS s3( file Array<String> )
PARTITIONED BY ( dt STRING )
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' COLLECTION ITEMS TERMINATED BY '\001' LINES TERMINATED BY '\n'
LOCATION 's3://PATH'
WHERE dt = to_date(from_unixtime(unix_timestamp()));
INSERT INTO TABLE S3
SELECT func(json) FROM tracksTable;
答案 0 :(得分:0)
我像那样管理它,
INSERT INTO TABLE S3
PARTITION(time)
SELECT func(json),from_unixtime(unix_timestamp(),'yyyy-MM-dd') AS time FROM tracksTable;