Skip to content

Commit

Permalink
fix more
Browse files Browse the repository at this point in the history
Signed-off-by: Bugen Zhao <[email protected]>
  • Loading branch information
BugenZhao committed Oct 8, 2023
1 parent ab85dc4 commit ed35e52
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/expr/core/src/expr/expr_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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()
Expand Down
16 changes: 8 additions & 8 deletions src/expr/core/src/expr/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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(),
)),
}
}

Expand All @@ -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(),
)),
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/frontend/src/expr/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -130,7 +130,7 @@ fn value_encoding_to_literal(
) -> risingwave_common::error::Result<Datum> {
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!()
Expand Down

0 comments on commit ed35e52

Please sign in to comment.