Operation not allowed: alter table add columns(lin

2019-03-02 18:13发布

问题:

We have Spark 2.1, Thrift JDBC/ODBC server configured with Hive 2.1.1 and using Beeline.

DDL statements like

CREATE TABLE, CREATE TABLE LIKE, CREATE TABLE LIKE, ALTER TABLE SET TBLPROPERTIES

works well.

But ALTER TABLE ADD COLUMNS fails

create table tbl1 (id int, c1 string, c2 string);
alter table tbl1 add columns (c3 string);

Error: org.apache.spark.sql.catalyst.parser.ParseException: Operation not allowed: alter table add columns(line 1, pos 0)

== SQL == alter table tbl1 add columns (c3 string) ^^^ (state=,code=0)

Any hint would be appreciated

回答1:

Looks like this is work in progress for Spark v2.x

https://issues.apache.org/jira/browse/SPARK-19261



回答2:

Try using HiveContext instead of spark Session. As some of the hive metastore queries does on work well with spark Session.