From 190b46e294d627de4b175655516e829221f992a1 Mon Sep 17 00:00:00 2001 From: xiangjinwu <17769960+xiangjinwu@users.noreply.github.com> Date: Wed, 15 Nov 2023 10:32:45 +0800 Subject: [PATCH] fix(frontend): refine error message on missing `force_append_only` (#13413) --- src/frontend/src/optimizer/plan_node/stream_sink.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/frontend/src/optimizer/plan_node/stream_sink.rs b/src/frontend/src/optimizer/plan_node/stream_sink.rs index cd48fda60e06b..5dbc7b8af62f4 100644 --- a/src/frontend/src/optimizer/plan_node/stream_sink.rs +++ b/src/frontend/src/optimizer/plan_node/stream_sink.rs @@ -238,14 +238,16 @@ impl StreamSink { format_desc: Option<&SinkFormatDesc>, ) -> Result { let frontend_derived_append_only = input_append_only; - let (user_defined_append_only, user_force_append_only) = match format_desc { + let (user_defined_append_only, user_force_append_only, syntax_legacy) = match format_desc { Some(f) => ( f.format == SinkFormat::AppendOnly, Self::is_user_force_append_only(&WithOptions::from_inner(f.options.clone()))?, + false, ), None => ( Self::is_user_defined_append_only(properties)?, Self::is_user_force_append_only(properties)?, + true, ), }; @@ -260,14 +262,14 @@ impl StreamSink { (false, true, false) => { Err(ErrorCode::SinkError(Box::new(Error::new( ErrorKind::InvalidInput, - "The sink cannot be 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 any UPDATE or DELETE message.", + format!("The sink cannot be 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 any UPDATE or DELETE message.", if syntax_legacy {"WITH"} else {"FORMAT ENCODE"}), ))) .into()) } (_, false, true) => { Err(ErrorCode::SinkError(Box::new(Error::new( ErrorKind::InvalidInput, - "Cannot force the sink to be append-only without \"FORMAT PLAIN\" or \"type='append-only'\".", + format!("Cannot force the sink to be append-only without \"{}\".", if syntax_legacy {"type='append-only'"} else {"FORMAT PLAIN"}), ))) .into()) }