I would like to add a new column to the table, but only if this column does not exist yet.
This works if the column does not exist:
ALTER TABLE MyTable ADD COLUMNS (mycolumn string);
But when I execute it a second time, I get an error message.
Column 'mycolumn' exists
When I try to use the "IF NOT EXISTS" syntax, which is supported for CREATE TABLE and ADD PARTITION, I get a syntax error:
ALTER TABLE MyTable ADD IF NOT EXISTS COLUMNS (mycolumn string);
FAILED: ParseException line 3:42 required (...)+ loop did not match anything at input 'COLUMNS' in add partition statement
I need something that can be done itempotently, so I can run my query if this column exists or not.
Mattd source
share