Bigdata, Hadoop ecosystem, Semantic IoT등의 프로젝트를 진행중에 습득한 내용을 정리하는 곳입니다.
필요한 분을 위해서 공개하고 있습니다.
문의사항은 gooper@gooper.com로 메일을
보내주세요.
임시 테이블(db_enc.hue_user_tmp)에서 데이터를 읽어서 partitioned table(db_enc.hue_user_test)에 데이터를 입력하는 impala SQL문장으로 모두 동일한 결과를 갖는다.
(임시 테이블과 최종 테이블의 table layout은 동일하며 최종 테이블에는 partition용 column이 한개 더 있다)
Kudu table을 이용하여 Parquet table을 생성하는 경우 Kudu table은 컬럼 순서가 달라서 컬럼을 일일이 지정해 주어야 하고 파티션 컬럼은 select의 마지막에 지정해줘야 한다
-- CTAS로 table을 생성하는 SQL 예시
1. create table db_enc.tb_hue_user partitioned by(partition_date) stored as parquet location '/ENC/DB_ENC/hue_user'
as select user_name, account, sentry_group, hue_last_login_date, hue_active_status, update_date, user_id, partition_date from db.hue_user;
2. create table db_enc.tb_query_history partitioned by (partition_date) stored as parquet location '/ENC/DB_ENC/query_history' as select * from db.query_history;
-- insert into 를 사용하는 다양한 SQL 예시 (아래의 4가지는 동일한 결과를 나타낸다.)
1.
insert into db_enc.hue_user_test(user_name, account, sentry_group, hue_last_login_date, hue_active_status, update_date, user_id) partition(partition_date='${partition_date}')
select user_name, account, sentry_group, hue_last_login_date, hue_active_status, update_date, user_id from db_enc.hue_user_tmp;
2.
insert into db_enc.hue_user_test(user_name, account, sentry_group, hue_last_login_date, hue_active_status, update_date, user_id) partition(partition_date)
select user_name, account, sentry_group, hue_last_login_date, hue_active_status, update_date, user_id, '${partition_date}' as partition_date from db_enc.hue_user_tmp;
3.
insert into db_enc.hue_user_test partition(partition_date)
select *, '${partition_date}' as partition_date from db_enc.hue_user_tmp;
4.
insert into db_enc.hue_user_test partition(partition_date='${partition_date}')
select * from db_enc.hue_user_tmp;
댓글 0
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
10 | Hive java connection 설정 | 구퍼 | 2013.04.01 | 2013 |
9 | banana pi에 hive 0.13.1+mysql(metastore)설치 | 총관리자 | 2014.09.09 | 2406 |
8 | Hive+mysql 설치 및 환경구축하기 | 구퍼 | 2013.03.07 | 2722 |
7 | spark-sql실행시 Caused by: java.lang.NumberFormatException: For input string: "0s" 오류발생시 조치사항 | 총관리자 | 2016.06.09 | 2803 |
6 | Hive 사용법 및 쿼리 샘플코드 | 구퍼 | 2013.03.07 | 2991 |
5 | 의사분산모드에서 presto설치하기 | 총관리자 | 2014.03.31 | 3050 |
4 | Spark에서 Serializable관련 오류및 조치사항 | 총관리자 | 2017.04.21 | 4901 |
3 | Hive Query Examples from test code (2 of 2) | 총관리자 | 2014.03.26 | 5030 |
2 | hive 2.0.1 설치및 mariadb로 metastore 설정 | 총관리자 | 2016.06.03 | 5187 |
1 | insert hbase by hive ... error occured after 5 hours..HMaster가 뜨지 않는 장애에 대한 복구 방법 | 총관리자 | 2014.04.29 | 7129 |