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

feat(frontend): show create table #7152

Merged
merged 6 commits into from
Jan 3, 2023
Merged

feat(frontend): show create table #7152

merged 6 commits into from
Jan 3, 2023

Conversation

BugenZhao
Copy link
Member

@BugenZhao BugenZhao commented Dec 30, 2022

I hereby agree to the terms of the Singularity Data, Inc. Contributor License Agreement.

What's changed and what's your intention?

  • Unify the normalization for CREATE statements, used for SHOW CREATE later.
  • Store full normalized CREATE definition for materialized views and tables.
  • Support SHOW CREATE TABLE.

We'll use this SQL to retrieve the original definition of the table, for the first version of ALTER TABLE ADD COLUMN. 🤣

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • All checks passed in ./risedev check (or alias, ./risedev c)

Documentation

If your pull request contains user-facing changes, please specify the types of the changes, and create a release note. Otherwise, please feel free to remove this section.

Types of user-facing changes

  • SQL commands, functions, and operators

Release note

Support SHOW CREATE TABLE.

Refer to a related PR or issue link (optional)

Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
@@ -76,7 +76,7 @@ pub fn gen_create_mv_plan(

let (database_id, schema_id) = session.get_database_and_schema_id_for_create(schema_name)?;

let definition = query.to_string();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this previous method, WITH options cannot be preserved. That'll be problematic for sinks.

@codecov
Copy link

codecov bot commented Dec 30, 2022

Codecov Report

Merging #7152 (27a0478) into main (1212793) will increase coverage by 0.03%.
The diff coverage is 71.57%.

@@            Coverage Diff             @@
##             main    #7152      +/-   ##
==========================================
+ Coverage   73.12%   73.15%   +0.03%     
==========================================
  Files        1053     1053              
  Lines      167974   167994      +20     
==========================================
+ Hits       122826   122902      +76     
+ Misses      45148    45092      -56     
Flag Coverage Δ
rust 73.15% <71.57%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/frontend/src/catalog/table_catalog.rs 96.21% <0.00%> (-1.01%) ⬇️
src/frontend/src/catalog/view_catalog.rs 0.00% <0.00%> (ø)
src/frontend/src/handler/create_table_as.rs 0.00% <0.00%> (ø)
src/frontend/src/handler/create_view.rs 0.00% <0.00%> (ø)
src/frontend/src/handler/query.rs 19.20% <0.00%> (ø)
src/frontend/src/handler/variable.rs 0.00% <0.00%> (ø)
src/frontend/src/session.rs 30.75% <0.00%> (+0.26%) ⬆️
src/frontend/src/handler/show.rs 65.71% <13.33%> (+0.92%) ⬆️
src/utils/pgwire/src/pg_response.rs 84.88% <66.66%> (-0.66%) ⬇️
src/frontend/planner_test/src/lib.rs 72.74% <100.00%> (-0.33%) ⬇️
... and 24 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@yezizp2012 yezizp2012 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job, rest LGTM.

src/frontend/src/handler/show.rs Show resolved Hide resolved
src/frontend/src/catalog/table_catalog.rs Show resolved Hide resolved
@BugenZhao BugenZhao added the user-facing-changes Contains changes that are visible to users label Dec 30, 2022
Copy link
Contributor

@chenzl25 chenzl25 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. A quick question, if we add a column to a table, how to modify the definition of the table? original definition + add column statement or regenerate a new definition.

@BugenZhao
Copy link
Member Author

regenerate a new definition.

I guess to show this one, according to the behavior of MySQL. 🤔 It always frankly shows how to create an empty table with the same schema in one-liner. BTW, for create table as, we should output create table (v int, v2 int) as well. 🥵

Signed-off-by: Bugen Zhao <i@bugenzhao.com>
@mergify mergify bot merged commit 0e90e6b into main Jan 3, 2023
@mergify mergify bot deleted the bz/show-create-table branch January 3, 2023 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature user-facing-changes Contains changes that are visible to users
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants