TIL icon indicating copy to clipboard operation
TIL copied to clipboard

HDFS 파일을 hive 테이블로 가져오기

Open occidere opened this issue 7 years ago • 1 comments

HDFS 파일을 hive 테이블로 가져오기

코드

테이블 생성

CREATE TABLE student (
    id string,
    name string
)
PARTITIONED BY (country string) -- 파티션 키는 테이블 컬럼에 포함될 수 없음
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
;

데이터 로드

LOAD DATA INPATH '/path/to/file.txt' INTO TABLE student PARTITION(country='korea');

참고

occidere avatar Jan 29 '19 02:01 occidere

파티셔닝 된 테이블인 경우 INSERT 는 아래와 같이 수행

-- 파티션 테이블 생성
CREATE TABLE company (
    name string,
    location string
) PARTITIONED BY (foundation_date string)
;

-- 파티션 테이블에 데이터 INSERT
INSERT INTO company PARTITION(foundation_date = '1999-06') VALUES ('NAVER', 'Seongnam');

occidere avatar Jan 17 '20 04:01 occidere