how to do partitions on subdirectories in hive

前端 未结 1 795
别跟我提以往
别跟我提以往 2021-01-26 23:47

I have directory structure like below in my hadoop,

`/hadoop/maindirec/subdirect1/file1
 /hadoop/maindirec/subdirect1/file2
 /hadoop/maindirec/subdirect2/file1 
         


        
相关标签:
1条回答
  • 2021-01-27 00:28

    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';

    0 讨论(0)
提交回复
热议问题