I have directory structure like below in my hadoop,
`/hadoop/maindirec/subdirect1/file1
/hadoop/maindirec/subdirect1/file2
/hadoop/maindirec/subdirect2/file1
You can use this code:(change and add column names as per your need)
CREATE EXTERNAL TABLE temp_table ( col1 int,col2 int) PARTITIONED BY ( subd string) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' STORED AS ORC LOCATION '/hadoop/maindirec';
ALTER TABLE temp_table ADD PARTITION (subd='subdirect1') LOCATION '/hadoop/maindirec/subdirect1/files1-100'
PARTITION (subd='subdirect2') LOCATION '/hadoop/maindirec/subdirect2/files1-100'
PARTITION (subd='subdirect3') LOCATION '/hadoop/maindirec/subdirect3/files1-100'
PARTITION (subd='subdirect4') LOCATION '/hadoop/maindirec/subdirect4/files1-100'
PARTITION (subd='subdirect5') LOCATION '/hadoop/maindirec/subdirect5/files1-100';