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 column comments #12663

Closed
neverchanje opened this issue Oct 8, 2023 · 4 comments · Fixed by #12849
Closed

support column comments #12663

neverchanje opened this issue Oct 8, 2023 · 4 comments · Fixed by #12849
Assignees
Milestone

Comments

@neverchanje
Copy link
Contributor

neverchanje commented Oct 8, 2023

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

There are many databases that allows commenting on columns, either during CREATE TABLE or after table creation through commands like COMMENT ON.

During CREATE TABLE

CREATE TABLE <table_name> (v INT(11) COMMENT 'table comment')

ALTER TABLE <table_name> MODIFY v INT(11) COMMENT = "new table comment"

COMMENT ON

COMMENT ON TABLE vehicles IS 'This table contains information about vehicles registered with MovR.';

SHOW TABLES FROM movr WITH COMMENT;
-- or
select obj_description('mySchema.myFunction'::regproc, 'pg_proc');
COMMENT ON CREATE TABLE (COMMENT 'cmt')
Snowflake Y Y
Redshift Y N
Oracle Y N
MySQL N Y
Hive N Y
FlinkSQL N Y
DuckDB N N

Apparently, column comment has been widely supported by many popular SQL systems. COMMENT ON is in favor of by primarily the PG and Oracle families while big data and MySQL families prefer the other. Snowflake supports the both.

I personally prefer Snowflake's syntax that combines both conventions:

COMMENT [IF EXISTS] ON <object_type> <object_name> IS '<string_literal>';

CREATE [ OR REPLACE ] <object_type> [ IF NOT EXISTS ] <object_name>
  [ <object_type_properties> ]
  [ <object_type_params> ]
  [ COMMENT = '<string_literal>' ]

DESC TABLE mytable;

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-1.3 milestone Oct 8, 2023
@xxchan
Copy link
Member

xxchan commented Oct 8, 2023

I have a concern that probably many users will use tools like DBeaver to read/write comments, so we'd better maintain PG compatibility for this feature.

@neverchanje
Copy link
Contributor Author

neverchanje commented Oct 9, 2023

Do you mean that DBeaver may be unable to recognize RisingWave's custom sytnax? This is a valid point. To be specific, my idea is that:

@xiangjinwu
Copy link
Contributor

Just adding some links:
https://www.postgresql.org/docs/16/sql-comment.html
https://www.postgresql.org/docs/16/functions-info.html#FUNCTIONS-INFO-COMMENT-TABLE
https://www.postgresql.org/docs/16/catalog-pg-description.html

The PostgreSQL doc suggests comments are not limited to columns, and they are stored separately then joined, rather than as an attribute of column.

@neverchanje
Copy link
Contributor Author

That's right. I guess that's why COMMENT ON comes into play. Commenting on CREATE TABLE is rather limited bcs only columns can have comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants