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): deprecate CREATE MATERIALIZED SOURCE syntax #7281

Merged
merged 16 commits into from
Jan 18, 2023

Conversation

xx01cyx
Copy link
Contributor

@xx01cyx xx01cyx commented Jan 10, 2023

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

What's changed and what's your intention?

From this PR on, we no longer support CREATE MATERIALIZED SOURCE syntax. Users will use CREATE TABLE instead of CREATE MATERIALIZED SOURCE to create a table with a connector associated with it. The remaining part of the SQL command is the same as before.

Also, users will be able to perform INSERT, DELETE, and UPDATE operations on a table with a connector associated with it.

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

Types of user-facing changes

  • Connector (sources & sinks)
  • SQL commands, functions, and operators

Release note

Create a table with a connector associated with it:

CREATE TABLE t (
    v int
) WITH (
    connector = ‘datagen’
) ROW FORMAT json;

CREATE_TABLE

Insert into a table with a connector associated with it:

INSERT INTO t VALUES (99999999);

INSERT 0 1

Update a table with a connector associated with it:

UPDATE t SET v = 11111111 WHERE v = 99999999;

UPDATE 1

Delete from a table with a connector associated with it:

DELETE FROM t WHERE v = 11111111;

DELETE 1

Misuse old syntax:

CREATE MATERIALIZED SOURCE s (
    v int
) WITH (
    connector = ‘datagen’
) ROW FORMAT json;

ERROR:  QueryError: sql parser error: CREATE MATERIALIZED SOURCE has been deprecated, use CREATE TABLE instead

Refer to a related PR or issue link

Close #5949

@xx01cyx xx01cyx added the user-facing-changes Contains changes that are visible to users label Jan 10, 2023
@hzxa21
Copy link
Collaborator

hzxa21 commented Jan 10, 2023

Does this PR maintain backward compatibility? In other words, if a user has already created a materialized source with CREATE MATERIALIZED SOURCE and upgrades the codes to include this PR, will the existing materialized source still be usable?

@xx01cyx xx01cyx marked this pull request as draft January 11, 2023 04:54
@xx01cyx
Copy link
Contributor Author

xx01cyx commented Jan 11, 2023

Does this PR maintain backward compatibility? In other words, if a user has already created a materialized source with CREATE MATERIALIZED SOURCE and upgrades the codes to include this PR, will the existing materialized source still be usable?

Not tested yet, but I'll try to make it backward-compatible.

@st1page
Copy link
Contributor

st1page commented Jan 11, 2023

Does this PR maintain backward compatibility? In other words, if a user has already created a materialized source with CREATE MATERIALIZED SOURCE and upgrades the codes to include this PR, will the existing materialized source still be usable?

I prefer to not maintain the compatibility at all. IIUC, currently our catalog and other meta format does not provide any compatibility guarantee. 🤔

@xx01cyx
Copy link
Contributor Author

xx01cyx commented Jan 11, 2023

Does this PR maintain backward compatibility? In other words, if a user has already created a materialized source with CREATE MATERIALIZED SOURCE and upgrades the codes to include this PR, will the existing materialized source still be usable?

Not tested yet, but I'll try to make it backward-compatible.

Per offline discussion with @st1page , backward capability is non-trivial and our system currently has no guarantee on it. We could find out a workaround if there are user requirements for this. So this PR might not include backward capability.

@hzxa21
Copy link
Collaborator

hzxa21 commented Jan 11, 2023

Does this PR maintain backward compatibility? In other words, if a user has already created a materialized source with CREATE MATERIALIZED SOURCE and upgrades the codes to include this PR, will the existing materialized source still be usable?

Not tested yet, but I'll try to make it backward-compatible.

Per offline discussion with @st1page , backward capability is non-trivial and our system currently has no guarantee on it. We could find out a workaround if there are user requirements for this. So this PR might not include backward capability.

Also discussed offline with @st1page. Maintaining compatibility is hard and may not worth it. If there is a need to upgrade version for the already deployed cases, we can write a simple tool to migrate old metadata to the new one on demand. @fuyufjh What do you think?

@codecov
Copy link

codecov bot commented Jan 13, 2023

Codecov Report

Merging #7281 (c471f60) into main (0bb78f6) will increase coverage by 0.02%.
The diff coverage is 67.82%.

@@            Coverage Diff             @@
##             main    #7281      +/-   ##
==========================================
+ Coverage   71.63%   71.66%   +0.02%     
==========================================
  Files        1083     1083              
  Lines      173692   173575     -117     
==========================================
- Hits       124428   124384      -44     
+ Misses      49264    49191      -73     
Flag Coverage Δ
rust 71.66% <67.82%> (+0.02%) ⬆️

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

Impacted Files Coverage Δ
src/connector/src/source/datagen/source/reader.rs 85.53% <ø> (ø)
src/frontend/src/handler/create_table_as.rs 0.00% <ø> (ø)
src/frontend/src/handler/drop_source.rs 0.00% <0.00%> (ø)
src/frontend/src/catalog/root_catalog.rs 67.81% <33.33%> (ø)
src/frontend/src/handler/alter_table.rs 85.40% <50.00%> (ø)
src/frontend/src/handler/drop_table.rs 83.33% <50.00%> (+0.31%) ⬆️
src/sqlparser/src/ast/mod.rs 88.76% <50.00%> (+<0.01%) ⬆️
src/sqlparser/src/parser.rs 91.99% <66.66%> (-0.11%) ⬇️
src/frontend/src/catalog/table_catalog.rs 93.58% <75.00%> (+0.60%) ⬆️
src/frontend/src/handler/create_source.rs 65.28% <77.77%> (+0.47%) ⬆️
... and 26 more

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

@xx01cyx xx01cyx marked this pull request as ready for review January 13, 2023 06:49
@xx01cyx
Copy link
Contributor Author

xx01cyx commented Jan 13, 2023

This PR is ready for review. PTAL @st1page @BugenZhao @tabVersion

Copy link
Member

@fuyufjh fuyufjh left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +63 to +65
# TODO: `show sources` should display connectors created by `create source` only.
# We should introduce `show connectors` to display all connectors created via both
# `create source` and `create table`.
Copy link
Member

Choose a reason for hiding this comment

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

🤔 In which case a user may want to show connectors? (IIUC connectors cannot be used to do anything)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe users should be able to view all created connectors. 🤔 cc. @st1page @yezizp2012

Copy link
Member

Choose a reason for hiding this comment

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

I think user may only care about which connector is used by some table and SHOW CREATE TABLE is already enough for it. 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

agree. no need for show connectors

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.

LGTM!

src/frontend/planner_test/src/lib.rs Outdated Show resolved Hide resolved
@@ -239,15 +239,7 @@ impl TableCatalog {
"Use `DROP MATERIALIZED VIEW` to drop a materialized view."
}
TableType::Index => "Use `DROP INDEX` to drop an index.",
TableType::Table => {
// TODO(Yuanxin): Remove this after unsupporting `CREATE MATERIALIZED SOURCE`.
// Note(bugen): may make this a method on `TableType` instead.
Copy link
Member

Choose a reason for hiding this comment

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

What about implementing this directly on TableType?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure whether it's a good idea to separate Table and TableWithConnector as two types. cc @st1page

Copy link
Member

Choose a reason for hiding this comment

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

Both LGTM. Never mind. 😄

src/frontend/src/optimizer/mod.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@tabVersion tabVersion left a comment

Choose a reason for hiding this comment

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

basically LGTM

Comment on lines +63 to +65
# TODO: `show sources` should display connectors created by `create source` only.
# We should introduce `show connectors` to display all connectors created via both
# `create source` and `create table`.
Copy link
Contributor

Choose a reason for hiding this comment

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

agree. no need for show connectors

@tabVersion
Copy link
Contributor

better add an error to tell the users that we no longer support CREATE MATERIALIZED SOURCE and let them know to use create table with connector instead

@st1page
Copy link
Contributor

st1page commented Jan 18, 2023

@Mergifyio refresh

@mergify
Copy link
Contributor

mergify bot commented Jan 18, 2023

refresh

✅ Pull request refreshed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change 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.

Tracking: new DML design
9 participants