Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drop a column of a sink table when the column is not referred #20277

Open
lmatz opened this issue Jan 23, 2025 · 1 comment
Open

drop a column of a sink table when the column is not referred #20277

lmatz opened this issue Jan 23, 2025 · 1 comment

Comments

@lmatz
Copy link
Contributor

lmatz commented Jan 23, 2025

Is your feature request related to a problem? Please describe.

dev=> create table sink_table (v1 int, v2 int, v3 int);
CREATE_TABLE

dev=> create table source (v1 int, v2 int, v3 int);
CREATE_TABLE

dev=> create sink s1 into sink_table as select v1, v2 from source with (type = 'append-only', force_append_only='true');
CREATE_SINK

dev=> alter table sink_table drop column v3;
ERROR:  Failed to run the query

Caused by:
  Invalid input syntax: dropping columns in the target table of sinks is not supported

It make senses that when v1 and v2 are referenced in the create sink statement, both columns cannot be dropped.

Even though v3 in sink_table is not referenced, RW disallows it to be dropped.

dev=> drop sink s1;
DROP_SINK

dev=> alter table sink_table drop column v3;
ALTER_TABLE

Although we can achieve the same purpose by first dropping all the sinks,
when the number of sinks is very large, it seems awkward to require users to drop and recreate all of the sinks.

Describe the solution you'd like

No response

Describe alternatives you've considered

No response

Additional context

No response

@github-actions github-actions bot added this to the release-2.3 milestone Jan 23, 2025
@lmatz
Copy link
Contributor Author

lmatz commented Jan 23, 2025

If it is hard to be implemented, we can provide the drop and recreate statements when returning the error
Caused by: Invalid input syntax: dropping columns in the target table of sinks is not supported
as a temporary solution to mitigate the tediousness. Sometimes, the existing sinks are not necessarily created by the same person and the one who tries to alter the column may also be a different person.

This is inspired by

dev=> create sink s1 into sink_table as select v1, v2 from source;
ERROR:  Failed to run the query

Caused by:
  Bind error: Only append-only sinks can sink to a table without primary keys. please try to add type = 'append-only' in the with option. e.g. create sink s into t as select * from t1 with (type = 'append-only')

I can copy the statement, without remembering what to write or looking up in the documentation.

@lmatz lmatz changed the title drop a column a sink table when the column is not referred drop a column of a sink table when the column is not referred Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant