hive操作s3資料

2021-07-29 18:15:48 字數 910 閱讀 8266

1、hive配置s3訪問許可權

2、建立表:

例如create external table table(

create_time bigint comment '獲取時的時間',

event_name string comment '事件名',

timestamp_ bigint comment '事件發生時間',

is_test string comment '是否測試資料,0|1是'

) comment '原始資料表'

partitioned by (pt_date string)

row format delimited fields terminated by '\t';

3、分割槽指定s3路徑:

按需要給hive表建立partition(如:按每天),關鍵是指定該partition的location是s3某路徑;

alter table table1 add partition(pt_date=20170328)  location 's3n://xx/yy/pt_date=20170328/';

注意:要有結尾的"/"

4、上傳資料到s3對應partition的目錄:

aws s3 cp data.txt s3://xx/yy/pt_date=20170328/

注意:要有結尾的"/"

5、在hive中查詢驗證。

1、檢視partition的location:

desc formatted table_test1 partition(pt_date='20160328');

2、指定table的location是's3n://a/b/',直接load data local,partition會自動從table整合location=『s3n://a/b/pt_date=pt_val』。

python 操作boto3操作s3

定時任務實時生成pdf,將檔案tornado用非同步io上傳到s3,有幾個坑記錄下 import re import boto3 import logging from multiprocessing.dummy import pool as threadpool aws region name c...

python呼叫aws api操作s3

首先需要配置金鑰和密碼 建立配置資料夾 mkdir aws 建立配置檔案 vim aws config default output json 輸出格式 region ap northeast 2 預設區域建立金鑰檔案 vim aws credentials default aws access k...

Hive中建立S3的外部表

hive中建立s3的外部表 資料在s3存放的資料是按時間緯度存放的,每天的資料存放在各自的目錄下,目錄結構如下截圖 每個目錄下面的資料是csv檔案,現在將其匯入到hive中進行查詢,通過建立對應的表結構 sql view plain copy hadoop到s3 hadoop distcp hdfs...