-
Notifications
You must be signed in to change notification settings - Fork 596
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
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
a617164
to
3562def
Compare
@@ -0,0 +1,284 @@ | |||
control substitution on |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this 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 |
There was a problem hiding this comment.
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?
_ => { | ||
// TODO: enhance error message for other formats |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. 🤪
There was a problem hiding this comment.
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
😇
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
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]>
Signed-off-by: xxchan <[email protected]>
There was a problem hiding this 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.
_ => { | ||
// TODO: enhance error message for other formats |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How I wish thiserror
provides something similar to this:
https://docs.rs/snafu/latest/snafu/derive.Snafu.html#providing-data-beyond-the-error-trait
Co-authored-by: Bugen Zhao <[email protected]>
"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(), |
There was a problem hiding this comment.
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]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏👏
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:
INCLUDE KEY clause must be set
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 youSource does not support PRIMARY KEY constraint
.Checklist
./risedev check
(or alias,./risedev c
)Documentation
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.