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: improve error msg for sink into table #19728

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions src/frontend/src/optimizer/plan_node/stream_sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,13 @@ impl StreamSink {

if !user_defined_primary_key_table && !sink_is_append_only {
return Err(RwError::from(ErrorCode::BindError(
"Only append-only sinks can sink to a table without primary keys. please try to add type = 'append-only' in the with option. e.g. create sink s into t as select * from t1 with (type = 'append-only')".to_string(),
"Only append-only sinks can sink to a table without primary keys. This sink is not append-only.\nPlease try to add (type = 'append-only', force_append_only = 'true') to the WITH options.".to_string(),
)));
}

if t.append_only && !sink_is_append_only {
return Err(RwError::from(ErrorCode::BindError(
"Only append-only sinks can sink to a append only table. please try to add type = 'append-only' in the with option. e.g. create sink s into t as select * from t1 with (type = 'append-only')".to_string(),
"Only append-only sinks can sink to a append only table. This sink is not append-only.\nPlease try to add (type = 'append-only', force_append_only = 'true') to the WITH options.".to_string(),
)));
}

Expand Down Expand Up @@ -491,21 +491,27 @@ impl StreamSink {
(false, true, false) => {
Err(ErrorCode::SinkError(Box::new(Error::new(
ErrorKind::InvalidInput,
// TODO:
format!(
"The sink cannot be append-only. Please add \"force_append_only='true'\" in {} options to force the sink to be append-only. \
"The sink is not append-only. Please add \"force_append_only='true'\" in {} options to force the sink to be append-only. \
Notice that this will cause the sink executor to drop DELETE messages and convert UPDATE messages to INSERT.",
if syntax_legacy { "WITH" } else { "FORMAT ENCODE" }
),
)))
.into())
}
(_, false, true) => {
Err(ErrorCode::SinkError(Box::new(Error::new(
ErrorKind::InvalidInput,
format!("Cannot force the sink to be append-only without \"{}\".", if syntax_legacy { "type='append-only'" } else { "FORMAT PLAIN" }),
)))
.into())
}
(_, false, true) => Err(ErrorCode::SinkError(Box::new(Error::new(
ErrorKind::InvalidInput,
format!(
"force_append_only='true' should be used together with {}.",
if syntax_legacy {
"type='append-only'"
} else {
"FORMAT PLAIN"
}
),
)))
.into()),
}
}

Expand Down
Loading