Hive partition tables

0 votes

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

Jan 3 in Big Data Hadoop by digger
• 27,620 points
78 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,140 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
462 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,140 points
56 views
0 votes
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,140 points
38 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,140 points
241 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,150 points
2,063 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,150 points
200 views
0 votes
10 answers

hadoop fs -put command?

copy command can be used to copy files ...READ MORE

answered Dec 7, 2018 in Big Data Hadoop by Sujay
10,579 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
772 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,140 points
297 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,140 points
145 views