Thursday, June 21, 2012

Hive CREATE TABLE AS SELECT Hadoop CTAS

When you search for CREATE TABLE AS SELECT in Hive you end up with documentation that simply doesn't give a simple example but rather shows complex examples that dig too dip but don't explain how to do it quickly. And here is the simple example:

CREATE TABLE T2 AS SELECT * FROM T1 WHERE C1 LIKE 'something%';

It works, I've just tried it.

==============================

Later addition. It works on a limited data. If your source table is huge then it's going to be a problem. The main problem is that this query allocates only one reducer by default. So you have two choices - either increase number of reducers or do the following:


  1. Copy a sample file to your directory
  2. Create a new table based on this file

2 comments:

Anonymous said...

Awesome it worked like charm

Anonymous said...

Thank you. Saved my hour