SemanticException adding partiton Hive table

Trying to create a partition in 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/' 

What makes the following conclusion

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

There are no sections in this table before this attempt to add.

 > show partitions stock_ticker; 

that leads to

 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 doubt that the column stock_symbol exists and has a type string.

The request is what steps should be taken to add this section?

+6
source share
1 answer

The solution would be to add split information to the definition of the stock_ticker table:

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

Then you can add external data to the table:

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

GL!

+5
source

Source: https://habr.com/ru/post/976573/


All Articles