Fix Hive `SemanticException [Error 10035]: Column repeated in partitioning columns`

While creating a new table with partition and you got this error:

SemanticException [Error 10035]: Column repeated in partitioning columns

You have redundantly included a column to be partitioned on your create table clause.

Say we want to create a user table partitioned by lastname the following create statement will generate the above error:

CREATE TABLE `user` (
  `firstname` STRING,
  `lastname` STRING,
  `age` INT
)
PARTITIONED BY (lastname STRING);

Moving of Columns to Partioned By Clause

To fix this, we need to remove the declaration of lastname column from the create table clause.

CREATE TABLE `user` (
  `firstname` STRING,
  `age` INT
)
PARTITIONED BY (`lastname` STRING);

More Verbose Error Message On Hive

Most of the time it’s hard to find what goes wrong with your Hive script. Hive’s using Log4J as it’s logging library and defaults to INFO and DRFA as its appender. The default log file can be found at /tmp/<user name>/hive.log. To get a more verbose ouput on errors you have to change Hive’s configuration hive.root.logger to ERROR and CONSOLE as appender. You can do this in three ways:

Hive CLI or Beeline

set hive.root.logger=WARN,console

Command Parameter

hive --hiveconf hive.root.logger=WARN,console

Hive Configuration File

Locate your hive configuration folder, and add the following config on your hive-site.xml.

<property>
  <name>hive.root.logger</name>
  <value>WARN,console</value>
</property>