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

Alter table options #1084

Open
killme2008 opened this issue Feb 26, 2023 · 16 comments
Open

Alter table options #1084

killme2008 opened this issue Feb 26, 2023 · 16 comments
Labels
C-enhancement Category Enhancements help wanted Extra attention is needed
Milestone

Comments

@killme2008
Copy link
Contributor

What type of enhancement is this?

API improvement, Configuration

What does the enhancement do?

For example, modify the table's TTL to 30 days:

ALTER TABLE monitor MODIFY TTL '30d';

Not all of the table options can be modified. The regions option can't be changed right now. Maybe we can manage a white list that contains alterable options.

Implementation challenges

How to make the change takes effect dynamically? I am not sure. I think we can implement a observer pattern for it.

@killme2008 killme2008 added the C-enhancement Category Enhancements label Feb 26, 2023
@killme2008 killme2008 added this to the v0.4 milestone Jun 20, 2023
@killme2008 killme2008 self-assigned this Jun 20, 2023
@killme2008
Copy link
Contributor Author

killme2008 commented Jul 31, 2023

After discussing and investigating, decide to use the following syntax:

alter table set options(ttl='30d', write_buffer_size='32mb');

The syntax for options is the same as that for creating tables. The other keywords at the options position can be used to set other table features.

@killme2008 killme2008 modified the milestones: v0.4, v0.5 Oct 11, 2023
@NiwakaDev
Copy link
Collaborator

I guess that we don't allow changing storage option.

@killme2008
Copy link
Contributor Author

killme2008 commented Nov 13, 2023

I guess that we don't allow changing storage option.

Yes, of course. I've done some preliminary work in #2051 .

@chienguo
Copy link

@killme2008 Hi! why did you stop this work? I am also interested in this issue, and I also noticed the discussion under #4394. Seems that alter table options and alter database options can be done parallelly. Can I have a try on this issue?

@evenyag
Copy link
Contributor

evenyag commented Aug 21, 2024

Feel free to try it. Could you please share your design and steps for implementing this feature?

@chienguo
Copy link

here is my rough design:

  • add AlterKind::ChangeOptions, record the option names that are about to change and their corresponding value
  • for all the places that deal with AlterKind, add support for ChangeOptions, like alter_expr_to_request, create_proto_alter_kind to create region proto, builder_with_alter_kind to construct a TableMetaBuilder actually to set table options for the upper AlterTableProcedure to use
  • for the table options white list, for now, I can only think of doing it in a hardcode way
  • modify parser to support input like this alter table set options(ttl='30d', write_buffer_size='32mb');

And where the proto file to generate greptime.v1.meta.rs locates? I cannot find it

@evenyag
Copy link
Contributor

evenyag commented Aug 21, 2024

And where the proto file to generate greptime.v1.meta.rs locates? I cannot find it

Are you looking for this?
https://github.com/GreptimeTeam/greptime-proto/tree/main/proto/greptime/v1

What's more, we also need to support altering options in the region engine and update the option of the region.

@chienguo
Copy link

Since tables are split and stored in regions, should altering table options result in region options being updated cascadingly? And besides that, do we also need to support altering region options directly?

@evenyag
Copy link
Contributor

evenyag commented Aug 21, 2024

should altering table options result in region options being updated cascadingly

Yes, we should also support altering region options.

@zyy17
Copy link
Collaborator

zyy17 commented Aug 22, 2024

here is my rough design:

  • add AlterKind::ChangeOptions, record the option names that are about to change and their corresponding value
  • for all the places that deal with AlterKind, add support for ChangeOptions, like alter_expr_to_request, create_proto_alter_kind to create region proto, builder_with_alter_kind to construct a TableMetaBuilder actually to set table options for the upper AlterTableProcedure to use
  • for the table options white list, for now, I can only think of doing it in a hardcode way
  • modify parser to support input like this alter table set options(ttl='30d', write_buffer_size='32mb');

And where the proto file to generate greptime.v1.meta.rs locates? I cannot find it

@chienguo I'm also very interested in this issue. Are you considering implementing it? If so, I can assign it to you.

@chienguo
Copy link

@zyy17 Yes, indeed, could you please assign it to me?

@evenyag
Copy link
Contributor

evenyag commented Aug 22, 2024

It's recommended to support altering region options first. We don't store the option in the manifest so we can update the version of the region here if the request is ModifyOptions.

let new_meta = match metadata_after_alteration(&version.metadata, request) {
Ok(new_meta) => new_meta,
Err(e) => {
sender.send(Err(e));
return;
}
};
// Persist the metadata to region's manifest.
let change = RegionChange {
metadata: new_meta.clone(),
};
self.handle_manifest_region_change(region, change, sender)

@WenyXu
Copy link
Member

WenyXu commented Aug 29, 2024

BTW, maybe we don't need the options keywords, the stmt without options is more concise.

ALTER TABLE table_name SET ( storage_parameter [= value] [, ... ] )
ALTER TABLE table_name UNSET ( storage_parameter [, ... ] )

@killme2008
Copy link
Contributor Author

BTW, maybe we don't need the options keywords, the stmt without options is more concise.

ALTER TABLE table_name SET ( storage_parameter [= value] [, ... ] )
ALTER TABLE table_name UNSET ( storage_parameter [, ... ] )

We may support altering other features in the future, so please keep the options keyword.

@WenyXu
Copy link
Member

WenyXu commented Aug 29, 2024

We may support altering other features in the future, so please keep the options keyword.

The ALTER TABLE table_name SET (ttl='30d', write_buffer_size='32mb'), can be considered as starting with LeftParen ((), so I think we can distinguish between SET ( and SET STH in the future.

@killme2008
Copy link
Contributor Author

We may support altering other features in the future, so please keep the options keyword.

The ALTER TABLE table_name SET (ttl='30d', write_buffer_size='32mb'), can be considered as starting with LeftParen ((), so I think we can distinguish between SET ( and SET STH in the future.

It's a bad practice to distinguish something with (.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category Enhancements help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

8 participants