From 07c7587ed9043f7d60126d2c806fde55b36ece65 Mon Sep 17 00:00:00 2001 From: tabVersion Date: Wed, 8 May 2024 14:59:23 +0100 Subject: [PATCH] output null for when we get NULL in bool Signed-off-by: tabVersion --- src/connector/src/sink/encoder/text.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/connector/src/sink/encoder/text.rs b/src/connector/src/sink/encoder/text.rs index 59ce90391282e..734ac8bd6a425 100644 --- a/src/connector/src/sink/encoder/text.rs +++ b/src/connector/src/sink/encoder/text.rs @@ -13,7 +13,7 @@ // limitations under the License. use risingwave_common::catalog::Schema; -use risingwave_common::types::{DataType, ScalarRefImpl, ToText}; +use risingwave_common::types::{DataType, ToText}; use super::RowEncoder; @@ -51,10 +51,11 @@ impl RowEncoder for TextEncoder { let datum = row.datum_at(col_index); let data_type = &self.schema.fields[col_index].data_type; if data_type == &DataType::Boolean { - result = datum - .unwrap_or(ScalarRefImpl::Bool(false)) - .into_bool() - .to_string(); + result = if let Some(scalar_impl) = datum { + scalar_impl.into_bool().to_string() + } else { + "NULL".to_string() + } } else { result = datum.to_text_with_type(data_type); } @@ -101,7 +102,7 @@ mod test { .encode_cols(&row, std::iter::once(0)) .unwrap() .as_str(), - "false" + "NULL" ); } }