From ed35e526689293c881dc3ba426668dfb9d8d778c Mon Sep 17 00:00:00 2001 From: Bugen Zhao Date: Sun, 8 Oct 2023 17:07:44 +0800 Subject: [PATCH] fix more Signed-off-by: Bugen Zhao --- src/expr/core/src/expr/expr_field.rs | 4 ++-- src/expr/core/src/expr/test_utils.rs | 16 ++++++++-------- src/frontend/src/expr/literal.rs | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/expr/core/src/expr/expr_field.rs b/src/expr/core/src/expr/expr_field.rs index eb4183edd2f57..a4101301308ed 100644 --- a/src/expr/core/src/expr/expr_field.rs +++ b/src/expr/core/src/expr/expr_field.rs @@ -16,7 +16,7 @@ use anyhow::anyhow; use risingwave_common::array::{ArrayImpl, ArrayRef, DataChunk}; use risingwave_common::row::OwnedRow; use risingwave_common::types::{DataType, Datum, ScalarImpl}; -use risingwave_common::util::value_encoding::deserialize_datum; +use risingwave_common::util::value_encoding::DatumFromProtoExt; use risingwave_pb::expr::expr_node::{RexNode, Type}; use risingwave_pb::expr::ExprNode; @@ -89,7 +89,7 @@ impl Build for FieldExpression { let RexNode::Constant(value) = second.get_rex_node().unwrap() else { bail!("Expected Constant as 1st argument"); }; - let index = deserialize_datum(value.body.as_slice(), &DataType::Int32) + let index = Datum::from_protobuf(value, &DataType::Int32) .map_err(|e| anyhow!("Failed to deserialize i32, reason: {:?}", e))? .unwrap() .as_int32() diff --git a/src/expr/core/src/expr/test_utils.rs b/src/expr/core/src/expr/test_utils.rs index d276413c02678..56ebcdfddf784 100644 --- a/src/expr/core/src/expr/test_utils.rs +++ b/src/expr/core/src/expr/test_utils.rs @@ -18,9 +18,9 @@ use std::num::NonZeroUsize; use num_traits::CheckedSub; use risingwave_common::types::{DataType, Interval, ScalarImpl}; -use risingwave_common::util::value_encoding::serialize_datum; +use risingwave_common::util::value_encoding::DatumToProtoExt; use risingwave_pb::data::data_type::TypeName; -use risingwave_pb::data::{PbDataType, PbDatum}; +use risingwave_pb::data::PbDataType; use risingwave_pb::expr::expr_node::Type::Field; use risingwave_pb::expr::expr_node::{self, RexNode, Type}; use risingwave_pb::expr::{ExprNode, FunctionCall}; @@ -57,9 +57,9 @@ pub fn make_i32_literal(data: i32) -> ExprNode { type_name: TypeName::Int32 as i32, ..Default::default() }), - rex_node: Some(RexNode::Constant(PbDatum { - body: serialize_datum(Some(ScalarImpl::Int32(data)).as_ref()), - })), + rex_node: Some(RexNode::Constant( + Some(ScalarImpl::Int32(data)).to_protobuf(), + )), } } @@ -70,9 +70,9 @@ fn make_interval_literal(data: Interval) -> ExprNode { type_name: TypeName::Interval as i32, ..Default::default() }), - rex_node: Some(RexNode::Constant(PbDatum { - body: serialize_datum(Some(ScalarImpl::Interval(data)).as_ref()), - })), + rex_node: Some(RexNode::Constant( + Some(ScalarImpl::Interval(data)).to_protobuf(), + )), } } diff --git a/src/frontend/src/expr/literal.rs b/src/frontend/src/expr/literal.rs index 28208ca66e435..2882243f93170 100644 --- a/src/frontend/src/expr/literal.rs +++ b/src/frontend/src/expr/literal.rs @@ -14,7 +14,7 @@ use risingwave_common::array::list_array::display_for_explain; use risingwave_common::types::{literal_type_match, DataType, Datum, ToText}; -use risingwave_common::util::value_encoding::{deserialize_datum, DatumToProtoExt}; +use risingwave_common::util::value_encoding::{DatumFromProtoExt, DatumToProtoExt}; use risingwave_pb::expr::expr_node::RexNode; use super::Expr; @@ -130,7 +130,7 @@ fn value_encoding_to_literal( ) -> risingwave_common::error::Result { if let Some(rex_node) = proto { if let RexNode::Constant(prost_datum) = rex_node { - let datum = deserialize_datum(prost_datum.body.as_ref(), ty)?; + let datum = Datum::from_protobuf(prost_datum, ty)?; Ok(datum) } else { unreachable!()