Can I add a new column to an existing spark table using the ALTER TABLE command ?
var query = "ALTER TABLE " + "global_temp." + tableName(0) + " ADD COLUMN " + newColumnName + " " + newColumnDatatype
var drt = spark.sql(query)
The above code raises the following error.
no viable alternative at input 'ALTER TABLE global_temp.people_ty ADD COLUMN' new_age integer
EDIT
The correct syntax is as follows
ALTER TABLE tablename ADD COLUMNS (newColumn newDataType)
But, it also throws the following error.
ALTER ADD COLUMNS does not support views.
You must drop and re-create the views for adding the new columns. Views: `global_temp`.`people_ty`
people_tyregistered usingcreateOrReplaceTempView?withColumnbefore you create a view out of it?