Support Questions
Find answers, ask questions, and share your expertise
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here. Want to know more about what has changed? Check out the Community News blog.

Error while adding partitions to views in hive

Error while adding partitions to views in hive


Hi All,


We are trying to create partitioned views on hive partitioned external tables.Tables are partitioned on customerid,orderid where as view is partitioned on customerid.


While trying to add partitions to views, sometimes we will pass already existing customerid.Then we are getting the below error and not understanding why it is not chekcing IF NOT EXISTS and then ignore the partition.


Please suggest what is going wrong here and how to solve this.


Query :

alter view viewname add if not exists partition(customerid=123);


the above query when trying to run is giving the below error:


Error while processing statement: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaException(message:java.lang.NullPointerException) at org.apache.hive.service.cli.operation.Operation.toSQLException( at org.apache.hive.service.cli.operation.SQLOperation.runQuery( at org.apache.hive.service.cli.operation.SQLOperation.access$800( at org.apache.hive.service.cli.operation.SQLOperation$BackgroundWork$ at Method) at at at org.apache.hive.service.cli.operation.SQLOperation$ at java.util.concurrent.Executors$ at at java.util.concurrent.ThreadPoolExecutor.runWorker( at java.util.concurrent.ThreadPoolExecutor$ at Caused by: org.apache.hadoop.hive.ql.metadata.HiveException:


Re: Error while adding partitions to views in hive


Hive's VIEW is ready only, please see below doc:

>> Views are read-only and may not be used as the target of LOAD/INSERT/ALTER.

Insert or update is not supported.