From 9a57bcd8b16e6aabfbc8bfce9539658bc4dbc42f Mon Sep 17 00:00:00 2001 From: Yang Xiufeng Date: Thu, 23 Feb 2023 13:14:20 +0800 Subject: [PATCH] feat: decimal encode to string in JSON. --- src/query/formats/src/field_encoder/json.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/query/formats/src/field_encoder/json.rs b/src/query/formats/src/field_encoder/json.rs index 3ee5557b06ca..be91f0c19196 100644 --- a/src/query/formats/src/field_encoder/json.rs +++ b/src/query/formats/src/field_encoder/json.rs @@ -13,6 +13,7 @@ // limitations under the License. use common_expression::types::array::ArrayColumn; +use common_expression::types::decimal::DecimalColumn; use common_expression::types::ValueType; use common_expression::Column; use common_io::constants::FALSE_BYTES_LOWER; @@ -87,4 +88,11 @@ impl FieldEncoderRowBased for FieldEncoderJSON { self.nested.write_tuple(columns, row_index, &mut buf, false); self.write_string_inner(&buf, out_buf, raw) } + + fn write_decimal(&self, column: &DecimalColumn, row_index: usize, out_buf: &mut Vec) { + let data = column.index(row_index).unwrap().to_string(); + out_buf.push(b'"'); + out_buf.extend_from_slice(data.as_bytes()); + out_buf.push(b'"'); + } }