partition column in hive

前端 未结 3 460
情书的邮戳
情书的邮戳 2021-01-05 05:20

I have to partition the table in hive with a column which is also part of the table.

For eg:

Table: employee

Co

3条回答
  •  死守一世寂寞
    2021-01-05 06:04

    Here's how to create a hive table with a partition on the column you specified

    CREATE TABLE employee (employeeId INT, employeeName STRING) PARTITIONED BY (employeeSalary INT);
    

    The partition column is specified in the PARTITIONED BY section.
    In the Hive shell you can run describe employee; and it will show all the columns in the table. With your CREATE TABLE you should see 4 columns, not the 3 you are trying to get.

    For your load command, you will want to specify all the partitions to write into. (I'm not very familiar with these, mostly basing off of http://wiki.apache.org/hadoop/Hive/LanguageManual/DML#Syntax

    So something like

    LOAD DATA LOCAL INPATH './examples/files/kv2.txt' OVERWRITE INTO TABLE employee PARTITION (employeeSalary=2000, employeeSalary=4000);
    

提交回复
热议问题