Tim
Tim

Reputation: 99408

How can I solve the error "file:/user/hive/warehouse/records is not a directory or unable to create one"?

hive> CREATE TABLE records (year STRING, temperature INT, quality INT)
    > ROW FORMAT DELIMITED
    >   FIELDS TERMINATED BY '\t';
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaException(message:file:/user/hive/warehouse/records is not a directory or unable to create one)

How can I solve the error?

where is /user/hive/warehouse/ located? In my local ext4 filesystems under Ubuntu, there is no /user/hive/warehouse/ such a path.

How can I get information about i.e. examine /user/hive/warehouse/?

Upvotes: 1

Views: 4179

Answers (1)

arunkvelu
arunkvelu

Reputation: 1743

You should create /user/hive/warehouse folder in hdfs file system before running hive commands.

Hive internally uses hadoop hdfs file system to store database data. You can check the hdfs directory path in hive-default.xml and/or hive-site.xml configuration file or in hive terminal, using below command

hive> set hive.metastore.warehouse.dir;

As mentioned Hive uses Hadoop, so

  • Hadoop must be installed and running status
  • HADOOP_HOME environment variable must be set

    export HADOOP_HOME=hadoop-install-dir

    export PATH=$PATH:$HADOOP_HOME/bin

  • Directories in hdfs file system must be created and given access to hive

    hadoop fs -mkdir -p /tmp

    hadoop fs -mkdir -p /user/hive/warehouse

    hadoop fs -chmod g+w /tmp

    hadoop fs -chmod g+w /user/hive/warehouse

To list directories in hdfs file system

hadoop fs -ls /user
hadoop fs -ls /
hadoop fs -ls /user/hive/ 

Hive Wiki page

Upvotes: 2

Related Questions