2017-02-03 1 views
1

내가 쪽모퉁이 파일을 만들었으며 임팔라 테이블로 가져 오려고합니다.임팔라 + 쪽모이 세공 파일

CREATE EXTERNAL TABLE `user_daily` (
`user_id` BIGINT COMMENT 'User ID', 
`master_id` BIGINT, 
`walletAgency` BOOLEAN, 
`zone_id` BIGINT COMMENT 'Zone ID', 
`day` STRING COMMENT 'The stats are aggregated for single days', 
`clicks` BIGINT COMMENT 'The number of clicks', 
`impressions` BIGINT COMMENT 'The number of impressions', 
`avg_position` BIGINT COMMENT 'The average position * 100', 
`money` BIGINT COMMENT 'The cost of the clicks, in hellers', 
`web_id` BIGINT COMMENT 'Web ID', 
`discarded_clicks` BIGINT COMMENT 'Number of discarded clicks from column "clicks"', 
`impression_money` BIGINT COMMENT 'The cost of the impressions, in hellers' 
) 
PARTITIONED BY (
year BIGINT, 
month BIGINT 
) 
STORED AS PARQUET 
LOCATION '/warehouse/impala/contextstat.db/user_daily/'; 

가 그럼 난이 스키마에이 파일을 복사 :

나는 아래 테이블 생성

parquet-tools schema user_daily/year\=2016/month\=8/part-r-00001-fd77e1cd-c824-4ebd-9328-0aca5a168d11.snappy.parquet 
message spark_schema { 
    optional int32 user_id; 
    optional int32 web_id (INT_16); 
    optional int32 zone_id; 
    required int32 master_id; 
    required boolean walletagency; 
    optional int64 impressions; 
    optional int64 clicks; 
    optional int64 money; 
    optional int64 avg_position; 
    optional double impression_money; 
    required binary day (UTF8); 
} 

을 그리고 나는

SELECT * FROM user_daily; 

I와 항목을 참조 할 때 get

File 'hdfs://.../warehouse/impala/contextstat.db/user_daily/year=2016/month=8/part-r-00000-fd77e1cd-c824-4ebd-9328-0aca5a168d11.snappy.parquet' 
has an incompatible Parquet schema for column 'contextstat.user_daily.user_id'. 
Column type: BIGINT, Parquet schema: 
optional int32 user_id [i:0 d:1 r:0] 

이 문제를 해결하는 방법을 알고 계십니까? 나는 BIGINT가 int_32와 같다고 생각한다. 테이블 구성표 또는 쪽매 세공 파일을 변경해야합니까?

답변

0

내가 CAST(... AS BIGINT) 사용 int32에서 int64에 마루 스키마를 변경 : 그냥 CREATE TABLE LIKE PARQUET 변형을 사용합니다. 그런 다음 이름으로 가입하지 않기 때문에 열의 순서를 변경해야합니다. 그런 다음 작동합니다.

1

BIGINT는 int64이므로 불만의 이유가됩니다. 그러나 반드시 자신이 사용해야하는 여러 유형을 알아야 할 필요는 없습니다. 임팔라는 그것을 할 수 있습니다.

The variation CREATE TABLE ... LIKE PARQUET 'hdfs_path_of_parquet_file' lets you skip the column definitions of the CREATE TABLE statement. The column names and data types are automatically configured based on the organization of the specified Parquet data file, which must already reside in HDFS.

+0

불행히도 이러한 해결책은 내가 원하는 것이 아닙니다. 위의 구조 표시가있는 특정 테이블이 있으며 여기서는 마루 파일을 변경하는 솔루션을 계속 사용하고자합니다. 다음 시도가 발생했습니다 : 다음 오류가 발생했습니다 :'ERROR : AnalysisException : 지원되지 않는 논리적 마루 종류 INT_16 (기본 유형은 INT32) 필드 web_id에 대한 것임 – United121

+0

오류 메시지는 테이블 정의에서 지정할 수있는 유형이 없음을 보여줍니다 그것은 파켓 파일에 포함 된 것과 호환 될 것입니다. 테이블 정의를 고수하고 Parquet 스키마를 변경하려면'int32'의 모든 인스턴스를'int64'로 변경하고'(INT_16)'부분을 제거하십시오. – Zoltan

+0

그러나 어떻게 그 체계에서'(INT_16)'부분을 제거 할 수 있습니까? 그것은'parquet-tools scheme '을 호출 한 후에 보여지며 이미 존재하는 파일을 기술하고 있는가? 이미 존재하는 파일에서 그것을 바꿀 수있는 방법이 있습니까? – United121

관련 문제