Skip to content

Commit e678a00

Browse files
committed
refactor: use serde in format validation match arm
1 parent e7b89c0 commit e678a00

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/sinks/clickhouse/config.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,15 +282,15 @@ impl ClickhouseConfig {
282282

283283
// Validate that batch_encoding is only compatible with ArrowStream format
284284
if self.format != Format::ArrowStream {
285+
let format_name = serde_json::to_value(&self.format)
286+
.ok()
287+
.and_then(|v| v.as_str().map(String::from))
288+
.unwrap_or_else(|| self.format.to_string());
289+
285290
return Err(format!(
286291
"'batch_encoding' is only compatible with 'format: arrow_stream'. \
287292
Found 'format: {}'.",
288-
match self.format {
289-
Format::JsonEachRow => "json_each_row",
290-
Format::JsonAsObject => "json_as_object",
291-
Format::JsonAsString => "json_as_string",
292-
Format::ArrowStream => "arrow_stream",
293-
}
293+
format_name
294294
)
295295
.into());
296296
}

0 commit comments

Comments
 (0)