Hive partition tables

–1 vote

Can we create manual partition for external tables ? if so how can we create ?

Jan 3 in Big Data Hadoop by digger
• 26,550 points
120 views

1 answer to this question.

0 votes

Yes, you can create manual partition. Here's how:

Open a new terminal and fire up hive by just typing hive. Create table on weather data.

CREATE EXTERNAL TABLE student ( name STRING, doj STRING)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘,’ LOCATION ‘ /hive/data/student’;

ROW FORMAT should have delimiters used to terminate the fields and lines like in the above example the fields are terminated with comma (“,”). The default location of Hive table is overwritten by using LOCATION. So the data now is stored in data/student folder inside hive.

Load the data in table

Load the data from HDFS to Hive using the following command:

LOAD DATA INPATH ‘hdfs:/data/2012.txt’ INTO TABLE student;

Partitioning of table

Hive stores tables in partitions. Partitions are used to divide the table into related parts. Partitions make data querying more efficient. For example in the above weather table the data can be partitioned on the basis of year and month and when query is fired on weather table this partition can be used as one of the column.

CREATE EXTERNAL TABLE IF NOT EXSISTS student ( name STRING, doj STRING)
PARTITIONED BY (year INT, month STRING)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘,’ LOCATION ‘ /hive/data/student’;

answered Jan 3 by Omkar
• 67,480 points

Related Questions In Big Data Hadoop

0 votes
1 answer

What is the difference between Hive internal tables and external tables?

Hive has a relational database on the ...READ MORE

answered Nov 19, 2018 in Big Data Hadoop by Neha
• 6,280 points
625 views
0 votes
1 answer

Command to partition table in Hive

Yes, You need to mention the below ...READ MORE

answered Dec 17, 2018 in Big Data Hadoop by Omkar
• 67,480 points
67 views
–1 vote
1 answer

How we can run spark SQL over hive tables in our cluster?

Open spark-shell. scala> import org.apache.spark.sql.hive._ scala> val hc = ...READ MORE

answered Dec 26, 2018 in Big Data Hadoop by Omkar
• 67,480 points
51 views
0 votes
1 answer

Error creating External Tables in Hive

The path which you have given for ...READ MORE

answered Feb 9 in Big Data Hadoop by Omkar
• 67,480 points
393 views
0 votes
1 answer

Hadoop Mapreduce word count Program

Firstly you need to understand the concept ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 10,670 points
2,742 views
0 votes
1 answer

hadoop.mapred vs hadoop.mapreduce?

org.apache.hadoop.mapred is the Old API  org.apache.hadoop.mapreduce is the ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 10,670 points
289 views
0 votes
10 answers

hadoop fs -put command?

put syntax: put <localSrc> <dest> copy syntax: copyFr ...READ MORE

answered Dec 7, 2018 in Big Data Hadoop by Aditya
13,585 views
0 votes
1 answer

Hadoop dfs -ls command?

In your case there is no difference ...READ MORE

answered Mar 16, 2018 in Big Data Hadoop by kurt_cobain
• 9,240 points
999 views
0 votes
1 answer

Unable to move Hadoop Hive tables from Source to Destination.

First, check the permissions of HDFS Directory ...READ MORE

answered Nov 30, 2018 in Big Data Hadoop by Omkar
• 67,480 points
495 views
0 votes
1 answer

Not able to insert in hive partition table

You have to add the partition before ...READ MORE

answered Dec 14, 2018 in Big Data Hadoop by Omkar
• 67,480 points
248 views