1

I have customer managed table in the hive, partition based on date and customerName. My directory structure is like below:

 user/hive/warehouse/test.db/customer/date1=2021-09-16/customerName=xyz

when I am doing show partitions customer it is not giving output. So I tried to add a partition with

MSCK REPAIR TABLE customer;

It give error Execution Error,return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask

ALTER TABLE customer ADD PARTITION (date1='2021-09-15') PARTITION (customerName='xyz');

It also give error ValidationFailureSemanticException partition spec {customername=xyz} contain non partition column

How can I add these partitions in hive metastore.

hive> show create table customer;
 OK
CREATE TABLE `customer`(
`act` string)
 PARTITIONED BY (
   `date1` string,
   `customername` string)
ROW FORMAT SERDE
  'org.apache.hadoop.hive.ql.io.orc.OrcSerde'
WITH SERDEPROPERTIES (
  'path'='hdfs://hdcluster/user/hive/warehouse/test.db/customer')
STORED AS INPUTFORMAT
  'org.apache.hadoop.hive.ql.io.orc.OrcInputFormat'
OUTPUTFORMAT
  'org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat'
LOCATION
  'hdfs://hdcluster/user/hive/warehouse/test.db/customer'
TBLPROPERTIES (
 'spark.sql.create.version'='2.4.0',
 'spark.sql.partitionProvider'='catalog',
 'spark.sql.sources.provider'='orc',
 'spark.sql.sources.schema.numPartCols'='2',
 'spark.sql.sources.schema.numParts'='1',
 'spark.sql.sources.schema.part.0'=
  '{\"type\":\"struct\",\"fields\": 
  [{\"name\":\"act\",\"type\":\"string\",\"nullable\":true,\"metadata\": 
  {}},           {\"name\":\"date1\",\"type\":\"string\",\"nullable\":true,\"metadata\":{}}, 
{\"name\":\"customername\",\"type\":\"string\",\"nullable\":true,\"metadata\ 
  ":{}}]}','spark.sql.sources.schema.partCol.0'='date1',
      'spark.sql.sources.schema.partCol.1'='customername',
      'transient_lastDdlTime'='1631781225')
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
vishwajeet Mane
  • 344
  • 1
  • 3
  • 13

1 Answers1

0

Try this:

ALTER TABLE customer 
ADD PARTITION (date1='2021-09-15',customerName='xyz')
LOCATION 
    'hdfs://hdcluster/user/hive/warehouse/test.db/customer/date1=2021-09-15/customerName=xyz';
Rich
  • 6,470
  • 15
  • 32
  • 53