Why won't the hive allow you to create an external table using CTAS?

In the hive, creating an external CTAS table is a semantic error, why? The table created by CTAS is atomic and the external data of the table is not deleted when the table is dropped, they do not seem to conflict.

+3


source to share


4 answers


Did I miss something?

Try this ... You should be able to create an external table using CTAS.



CREATE TABLE ext_table LOCATION '/user/XXXXX/XXXXXX' 
AS SELECT * from managed_table;

      

I was able to create it. I am using 0.12.

+3


source


In Hive, when we create a table (NOT external), the data will be stored in / user / hive / storage. But during the creation of the external hive table, the file will be somewhere else, we just point to this hdfs directory and expose the data as a hive table to run queries on the hive, etc. This SO answer more accurately Create a beehive table using "how to select" or "like" and also specify a delimiter



+2


source


I think this is a semantic error because it misses the most inappropriate parameter for defining an external table, namely. External location of the data file! by definition, 1. External means that the data is outside the control of the hive, which is outside the data warehouse of the store. 2. If the table is lost, the data remains unchanged, only the table definition is removed from the hive metastar. so, me. if CTAS is with a managed table, the new ext table will have a file in the warehouse to be dropped by the mailing table which makes wrong error # 2 II. if CTAS is with a different external table, the two tables point to the same file location.

0


source


This sometimes happens to me because I am not logged in as the correct user with the correct rights.

0


source







All Articles