Skip to content

Commit

Permalink
output null for when we get NULL in bool
Browse files Browse the repository at this point in the history
Signed-off-by: tabVersion <[email protected]>
  • Loading branch information
tabVersion committed May 8, 2024
1 parent 2ffdc53 commit 07c7587
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/connector/src/sink/encoder/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -101,7 +102,7 @@ mod test {
.encode_cols(&row, std::iter::once(0))
.unwrap()
.as_str(),
"false"
"NULL"
);
}
}

0 comments on commit 07c7587

Please sign in to comment.