Best unofficial Apache Server developers community
Username
Forgot password?
Sign in with Twitter account
Sign in with Facebook account

Create temporary table in Hive?

0

66 views

Does Hive support temporary tables? I can't find it in the apache docs.

asked March 21, 2011 6:59 pm CDT
posted via StackOverflow

1 Answers

0
Best answer
 

I don't think Hive has temporary tables the same as something like SQL Sever does. You can do something like temporary tables with Hive though.

If you create a table with the schema your temporary table needs, then do a query populating the table before you run the query needing the data, it will act like a temporary table.

The steps would be:

  1. Create Table
  2. Fill Table: INSERT OVERWRITE TABLE temptbl <select_query>
  3. Run query

When you run your query you can use temptbl like any other table. The INSERT OVERWRITE will overwrite all data in the table so it will only be populated with data for that run. The data persists, so if you re-use the table without re-populating it, you will be using the data from whatever the last run was.

This can definitely run into issues if the same table will be needed at the same time but for different data...

From what I've been able to find, this is the only solution to a 'temporary' table in Hive right now.

answered March 22, 2011 5:14 pm CDT

Your answer

Join with account you already have


Sign in with Twitter account
Sign in with Facebook account
Sign in with Google Friend Connect

Preview
Similar questions
Hive with Lucene
January 31, 2011
Hadoop/hive metastore
August 7, 2009
Create table in hbase
February 22, 2011