Search code examples
apache-sparkapache-spark-sqlviewhiveimpala

How to add comments to a view created through Spark


I'm trying to add table and column comments to a view that was created through PySpark using:

Create Or Replace View test_v (name, colour) As Select name_t, colour_t From my_table

I tried to use query like below through Sparksql and impala to add comments to the column, but it didn't work as it doesn't seem to be the right Sparksql command, and Impala doesn't accept alter table on a view. How should I do this? Thanks for your help!

Alter table test_v alter name set comment 'name of the piece'

Solution

  • According to the Alter View, you can't modify or add comment for a column directly, you can create or replace the view with comments like this:

    Create Or Replace View test_v (name comment 'This is name field', colour comment 'This is colour filed') As Select name_t, colour_t From my_table