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

Support table level comment #3836

Closed
shuiyisong opened this issue Apr 29, 2024 · 5 comments · Fixed by #4042
Closed

Support table level comment #3836

shuiyisong opened this issue Apr 29, 2024 · 5 comments · Fixed by #4042
Labels
docs-required This change requires docs update. good first issue Good for newcomers

Comments

@shuiyisong
Copy link
Contributor

What problem does the new feature solve?

Currently we only have column level comment. Adding table level comment can attach some information about the table, e.g: the table is auto-created by schemaless write from influxdb line protocol.

What does the feature do?

  1. add option for comment on create table
  2. display the comment in show create table

an example table option on creation could be

CREATE TABLE if not exists monitor (
  host STRING,
  ts TIMESTAMP(9) DEFAULT CURRENT_TIMESTAMP() TIME INDEX,
  cpu FLOAT64 DEFAULT 0,
  memory FLOAT64,
  PRIMARY KEY(host)) ENGINE=mito WITH(COMMENT='create by human');

Implementation challenges

tips:

  1. see here for table option validation
@waynexia
Copy link
Member

waynexia commented Apr 29, 2024

Reference: table comment parser in MySQL - https://dev.mysql.com/doc/refman/8.0/en/create-table.html

@imp2002
Copy link

imp2002 commented Apr 29, 2024

I'm interested in this task, can you assign it to me?

@tisonkun
Copy link
Contributor

tisonkun commented Apr 30, 2024

If we use COMMENT="..." we can reuse the OptionMap code. I don't know if sqlparser-rs supports COMMENT "..." syntax now.

    /// Table options in `WITH`. All keys are lowercase.
    pub options: OptionMap,

@tisonkun
Copy link
Contributor

tisonkun commented Apr 30, 2024

It seems MySQL support COMMENT="..." also. We can thus reuse the options parse code and focus on conveying the comment.

I guess add the key "comment" in the allow list of pub fn validate_table_option(key: &str) -> bool should be a good start - FYI @imp2002

@waynexia
Copy link
Member

Just recall that there is a relative field in TableInfo for storing table comments:

/// Comment of the table.
#[builder(default, setter(into))]
pub desc: Option<String>,

We can consider extracting the comment from table option and storing it here.

@tisonkun tisonkun added C-bug Category Bugs and removed C-bug Category Bugs labels May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-required This change requires docs update. good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants