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

refactor: refine error message and test for FORMAT UPSERT #17397

Merged
merged 10 commits into from
Jun 24, 2024
Merged

Conversation

xxchan
Copy link
Member

@xxchan xxchan commented Jun 21, 2024

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

What's changed and what's your intention?

Motivation: previously the error message is very silly:

  1. It first errors with INCLUDE KEY clause must be set
  2. After it's added, it errors with Primary key must be specified

Why can't we hint enough information in one shot?

For CREATE SOURCE UPSERT, it's even more silly: It will go through the same error above, then 3. tell you Source does not support PRIMARY KEY constraint.

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.

@xxchan xxchan marked this pull request as ready for review June 21, 2024 10:02
@xxchan xxchan requested a review from a team as a code owner June 21, 2024 10:02
Copy link
Member Author

xxchan commented Jun 21, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @xxchan and the rest of your teammates on Graphite Graphite

@xxchan xxchan changed the title refactor: move json schema to codec crate refactor: refine error message and test for FORMAT UPSERT Jun 21, 2024
@xxchan xxchan force-pushed the include-test branch 2 times, most recently from a617164 to 3562def Compare June 21, 2024 10:09
@@ -0,0 +1,284 @@
control substitution on
Copy link
Member Author

Choose a reason for hiding this comment

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

The changes to this test can be reviewed commit by commit

Copy link
Contributor

Choose a reason for hiding this comment

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

what does this command mean?

Copy link
Member Author

Choose a reason for hiding this comment

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

Replace ${} to env vars in the slt.

To use ${RISEDEV_KAFKA_WITH_OPTIONS_COMMON}, this needs to be opened.

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.

LGTM, thanks for refining the error msg

@@ -0,0 +1,284 @@
control substitution on
Copy link
Contributor

Choose a reason for hiding this comment

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

what does this command mean?

Comment on lines +1397 to +1398
_ => {
// TODO: enhance error message for other formats
Copy link
Contributor

@xiangjinwu xiangjinwu Jun 24, 2024

Choose a reason for hiding this comment

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

Debezium (DebeziumMongo), Canal, Maxwell all require table rather than source.

Unsure about none / native.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I thought only PLAIN is for SOURCE. Now I'm not sure when I found none/native. 🤪

Copy link
Contributor

Choose a reason for hiding this comment

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

native is for datagen, so it should work in both source and table. Not sure about None 😇

Copy link
Member Author

Choose a reason for hiding this comment

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

According to the commend, native is for schema change

Copy link
Member

Choose a reason for hiding this comment

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

Link to the original PR: #12306

TL;DR: Keywords like NATIVE will never be explicitly written by users in their SQL, but appear after normalization and persistence. When we're going to do schema change, we have to reparse the SQL (under current implementation) so NATIVE must be accepted as a keyword.

xxchan added 7 commits June 24, 2024 12:25
Signed-off-by: xxchan <[email protected]>
Signed-off-by: xxchan <[email protected]>
Signed-off-by: xxchan <[email protected]>
Signed-off-by: xxchan <[email protected]>
Signed-off-by: xxchan <[email protected]>
Signed-off-by: xxchan <[email protected]>
Signed-off-by: xxchan <[email protected]>
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.

L🥰TM. The tests for error reporting is quite comprehensive.

src/frontend/src/handler/create_source.rs Show resolved Hide resolved
Comment on lines +1397 to +1398
_ => {
// TODO: enhance error message for other formats
Copy link
Member

Choose a reason for hiding this comment

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

Link to the original PR: #12306

TL;DR: Keywords like NATIVE will never be explicitly written by users in their SQL, but appear after normalization and persistence. When we're going to do schema change, we have to reparse the SQL (under current implementation) so NATIVE must be accepted as a keyword.

@@ -750,6 +750,18 @@ pub(crate) fn bind_all_columns(
}
}

fn hint_upsert(encode: &Encode) -> String {
format!(
r#"Hint: For FORMAT UPSERT ENCODE {encode:}, INCLUDE KEY must be specified and the key column must be used as primary key.
Copy link
Member

Choose a reason for hiding this comment

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

@xxchan xxchan enabled auto-merge June 24, 2024 05:37
"Primary key must be specified to {} when creating source with FORMAT UPSERT ENCODE {:?}",
key_column_name.unwrap(), encode))))
"Primary key must be specified to {}\n\n{}",
include_key_column_name.unwrap(),
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: if let Some to avoid this unwrap.

Signed-off-by: xxchan <[email protected]>
@xxchan xxchan added this pull request to the merge queue Jun 24, 2024
Copy link
Member

@stdrc stdrc left a comment

Choose a reason for hiding this comment

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

👏👏

Merged via the queue into main with commit 4f8bfc4 Jun 24, 2024
31 of 32 checks passed
@xxchan xxchan deleted the include-test branch June 24, 2024 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants