Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SemanticException adding partiton Hive table

Tags:

hive

hiveql

Attempting to create a partition on a Hive table with the following:

> alter table stock_ticker add if not exists
> partition(stock_symbol='ASP')
> location 'data/stock_ticker_sample/stock_symbol=ASP/'

Which produces the following output

FAILED : SemanticException table is not partitioned but partition spec exists: {stock_symbol=ASP} 

There are no partitions on this table prior to this addition attempt

> show partitions stock_ticker;

which results in

FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. 
Table stock_ticker_sample is not a partitioned table

There is no question that the stock_symbol column exists and is of type string.

The query is what steps need to be taken in order to add this partition?

like image 556
eddyoc Avatar asked Oct 10 '14 15:10

eddyoc


1 Answers

Solution would be to add partitioning info into the definition of stock_ticker table:

CREATE EXTERNAL TABLE stock_ticker (
... 
)
PARTITIONED BY (stock_symbol STRING);

Then easily you can add external data to your table by:

> alter table stock_ticker add if not exists
> partition(stock_symbol='ASP')
> location 'data/stock_ticker_sample/stock_symbol=ASP/'

GL!

like image 136
www Avatar answered Sep 23 '22 03:09

www