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(cdc): map upstream table schema automatically for cdc table #16986

Merged
merged 42 commits into from
Jun 10, 2024

Conversation

StrikeW
Copy link
Contributor

@StrikeW StrikeW commented May 29, 2024

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

Automatically map the upstream table schema when creating a CDC table from mysql-cdc or postgres-cdc source.
We use the sea-schema crate to read the upstream schema.

  • Add a ExternalTableImpl as an interface to read external table schema
  • Some refactor to move mysql related code to mysql.rs.
  • The * cannot be used with column definitions, for example create table t (v1 int, *) is prohibited.

Example:

dev=> create table supplier (*) from pg_source table 'public.supplier';
CREATE_TABLE
dev=> describe supplier;
       Name        |       Type        | Is Hidden | Description
-------------------+-------------------+-----------+-------------
 s_suppkey         | bigint            | false     |
 s_name            | character varying | false     |
 s_address         | character varying | false     |
 s_nationkey       | bigint            | false     |
 s_phone           | character varying | false     |
 s_acctbal         | numeric           | false     |
 s_comment         | character varying | false     |
 primary key       | s_suppkey         |           |
 distribution key  | s_suppkey         |           |
 table description | supplier          |           |
(10 rows)

close #16443

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added test labels as necessary. See details.
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
  • All checks passed in ./risedev check (or alias, ./risedev c)
  • My PR changes performance-critical code. (Please run macro/micro-benchmarks and show the results.)
  • My PR contains critical fixes that are necessary to be merged into the latest release. (Please check out the details)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.

@StrikeW StrikeW added the user-facing-changes Contains changes that are visible to users label May 29, 2024
@StrikeW StrikeW force-pushed the siyuan/auto-map-schema branch from 36087b2 to 3117fac Compare May 30, 2024 15:07
@StrikeW StrikeW requested a review from xiangjinwu June 4, 2024 05:57
Copy link
Contributor

@st1page st1page left a comment

Choose a reason for hiding this comment

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

Generally LGTM
It is recommended to split "code movement and refactoring" and "functional logic changes" into two separate PRs next time

Copy link
Contributor

@st1page st1page left a comment

Choose a reason for hiding this comment

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

Btw, Can you show an error message indicating that the database cannot be connected? I guess it would be very helpful for users to know that it is the frontend which need to be connected to the source database.

@StrikeW
Copy link
Contributor Author

StrikeW commented Jun 6, 2024

Btw, Can you show an error message indicating that the database cannot be connected? I guess it would be very helpful for users to know that it is the frontend which need to be connected to the source database.

Here is an example

dev=> create table mysql_all_types (*) from mysql_mydb table 'mydb.mysql_mydb';
ERROR:  Failed to run the query

Caused by these errors (recent errors listed first):
  1: connector error
  2: pool timed out while waiting for an open connection

Copy link
Member

@BugenZhao BugenZhao left a comment

Choose a reason for hiding this comment

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

Can we adopt the new inline source style introduced in #16449?

e2e_test/source/cdc_inline/auto_schema_map_mysql.slt Outdated Show resolved Hide resolved
Comment on lines +41 to +44
hostname = '${MYSQL_HOST:localhost}',
port = '${MYSQL_TCP_PORT:8306}',
username = 'root',
password = '${MYSQL_PWD:}',
Copy link
Member

Choose a reason for hiding this comment

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

We can use ${RISEDEV_MYSQL_WITH_OPTIONS_COMMON}.

Copy link
Member

Choose a reason for hiding this comment

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

Better to organize it under the new folder e2e_test/source_inline.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will refactor in another pr.

Copy link

gitguardian bot commented Jun 9, 2024

️✅ There are no secrets present in this pull request anymore.

If these secrets were true positive and are still valid, we highly recommend you to revoke them.
Once a secret has been leaked into a git repository, you should consider it compromised, even if it was deleted immediately.
Find here more information about risks.


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@StrikeW StrikeW enabled auto-merge June 10, 2024 05:42
@StrikeW StrikeW force-pushed the siyuan/auto-map-schema branch from b32370c to 38ff10e Compare June 10, 2024 06:35
@StrikeW StrikeW disabled auto-merge June 10, 2024 07:07
@StrikeW StrikeW enabled auto-merge June 10, 2024 07:07
@StrikeW StrikeW requested a review from st1page June 10, 2024 07:09
@StrikeW StrikeW added this pull request to the merge queue Jun 10, 2024
Merged via the queue into main with commit 45d3b76 Jun 10, 2024
28 of 29 checks passed
@StrikeW StrikeW deleted the siyuan/auto-map-schema branch June 10, 2024 08:41
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.

Support creating table for CDC connectors with the * syntax
3 participants