2013-03-27 1 views
0

하이브 테이블의 열 중 하나에서 키 - 값 쌍을 저장하고 싶습니다. Hive의 복잡한 데이터 유형 맵은 해당 구조를 지원합니다. 하이브를 사용하여 파이썬 스크립트를 감속기로 사용하여지도 데이터 유형 열로드

(이것은 내가, 내가 이런 식으로 압축 할 더 많은 열이를 수행 할 수 있으려면 무엇의 장난감 예입니다) 그래서 나는이 같은 테이블을 만들 :

hive>DESCRIBE transaction_detailed; 
OK 
id STRING 
time STRING 
Time taken: 0.181 seconds 

hive>DROP TABLE IF EXISTS transactions; 
hive>CREATE EXTERNAL TABLE transactions(
    id STRING, 
    time_map MAP<STRING, INT> 
    ) 
partitioned by (dt string) 
row format delimited fields terminated by '\t' collection items terminated by ',' map keys terminated by ':' lines terminated by '\n' 
location 's3://my_loaction/transactions/'; 

코드에서 설명한대로 감속기를 사용하여지도 열을로드하려고합니다. 구조체 의 time_map은 { "min": 시간, "max": 시간, "average": 시간 , "total": 시간}

hive>FROM(FROM transaction_detailed 
MAP transaction_detailed.id, transaction_detailed.time 
USING "python unity mapper -- splits the same thing out as it takes it" 
AS id, time 
cluster by id) transaction_time_map 
insert overwrite table transactions partition(dt="2013-27-03") 
REDUCE transaction_time_map.id, transaction_time_map.time 
USING "python reducer which takes time_stamp sequence for a single id and summarizes them using min, max, average and total and supposed to insert into map" 
as id, time_map; 

하지만 얻을 이런 오류 :

내 파이썬 감속기를 사용하여 맵 항목에로드 어떻게
FAILED: Error in semantic analysis: Line 6:23 Cannot insert into target table because column number/types are different "two_day": Cannot convert column 8 from string to map<string,int>. 

?

답변

0

위 질문에 대한 대답은 하이브에 str_to_map(text[, delimiter1, delimiter2]) 기능을 사용하는 것입니다.

관련 문제