2

Looks like hive replace columns is not working with spark 2.2.1 and also with 2.3.1

alterSchemaSql : alter table myschema.mytable replace columns (a int,b int,d int)
Exception in thread "main" org.apache.spark.sql.catalyst.parser.ParseException: 
Operation not allowed: alter table replace columns(line 2, pos 6)

Looks like it's been fixed for ADD COLUMNS 2.2 version onwards. It also works for me but replace columns still fails.

Operation not allowed: alter table add columns(line 1, pos 0)

Following docs says it should be supported. Not sure why it's failing for me. https://spark.apache.org/docs/2.2.0/sql-programming-guide.html#supported-hive-features

https://docs.databricks.com/spark/latest/spark-sql/language-manual/alter-table-or-view.html#replace-columns

2
  • Do you mean rename column or replace column? Commented Dec 18, 2018 at 5:44
  • replace column. Commented Dec 18, 2018 at 16:32

1 Answer 1

0

Sadly, it seems ALTER TABLE table REPLACE is not implemented by Spark.

Take a look at SparkSqlParser.scala: SparkSqlParser.scala

There, you can see, what SQL statements work with Spark.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.