Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Hive, mail # user - create external table as select with location?


Copy link to this message
-
create external table as select with location?
Igor Tatarinov 2012-04-04, 17:33
Is it possible to do something like this:

CREATE EXTERNAL TABLE T
LOCATION 's3://...'
AS
SELECT ...;

I would rather not fix the schema for T so that I can easily change the
SELECT query and its underlying tables.
Because of that, I don't want to define the table first. Instead, I have to
save the data into a temp table:

CREATE TABLE tmp AS
SELECT ...;

CREATE EXTERNAL TABLE T LIKE tmp
LOCATION 's3://...';

INSERT OVERWRITE TABLE T
SELECT * FROM tmp;

which seems to be slower than using a single INSERT with the original
SELECT.