greptimedb icon indicating copy to clipboard operation
greptimedb copied to clipboard

Alter table supports rename columns

Open killme2008 opened this issue 2 years ago • 6 comments

What problem does the new feature solve?

GreptimeDB already supports altering table schema by adding, removing columns or renaming the table name. But we don't support renaming columns.

For example:

ALTER TABLE table_name
RENAME COLUMN old_name TO new_name;

What does the feature do?

Rename a column name by alter statement.

Implementation challenges

Do we allow renaming a time index column? If so, there are some tricky problems that have to be processed:

  • The old data before renaming can be read.
  • Flushing and compaction work properly in this case.

killme2008 avatar Feb 14 '23 09:02 killme2008

It's not done.

killme2008 avatar Jun 12 '23 15:06 killme2008

Does greptimedb have plans to support modify or already have something similar? I'd like to use not only this but also modify:

alter table test_table modify column_name double not null;

I'd like to change null constraint for columns.

NiwakaDev avatar Sep 12 '23 23:09 NiwakaDev

I'm afraid column alternation is not an easy task. @evenyag can you confirm that?

MichaelScofield avatar Sep 13 '23 01:09 MichaelScofield

Does greptimedb have plans to support modify or already have something similar? I'd like to use not only this but also modify:

alter table test_table modify column_name double not null;

I'd like to change null constraint for columns.

It is hard to modify a column from nullable to not nullable since existing data may contain null. Changing a not null column to nullable is easier.

evenyag avatar Sep 17 '23 07:09 evenyag

I think this is very relevant to https://github.com/GreptimeTeam/greptimedb/issues/3517

KKould avatar Apr 15 '24 08:04 KKould

I think this is very relevant to #3517

Yes, relevant to column metadata changing.

killme2008 avatar Apr 15 '24 21:04 killme2008