Pacific-Design.com

    
Home Index

1. Apache Hive

2. Load CSV To Hive

Apache Hive / Load CSV To Hive /

Loading CSV File to Hive Table

set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;
set hive.exec.parallel=true;

DROP TABLE music.artist_royalty;

CREATE EXTERNAL TABLE IF NOT EXISTS music.artist_royalty
(
  period string,
  acct_num string,
  acct_name string,
  product string,
  title string,
  config string,
  sales_type string,
  retail_price float,
  revenue_type string
)
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde'
WITH SERDEPROPERTIES (
   "separatorChar" = ",",
   "quoteChar"     = "\"",
   "escapeChar"    = "\\"
)
LOCATION
  's3n://kduraj/data/artist-royalty'
;

-- use when partions only
-- USE music;
-- MSCK REPAIR TABLE music.artist;

SHOW CREATE TABLE music.artist_royalty;
SELECT * FROM music.artist_royalty LIMIT 100;