Skip to content

Commit

Permalink
refine
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, 2024
1 parent 56fa90f commit 67df70e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/expr/impl/src/scalar/vnode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ use risingwave_expr::{build_function, expr_context, Result};

#[derive(Debug)]
struct VnodeExpression {
/// `Some` if it's from the first argument of user-facing function `VnodeUser` (`rw_vnode`),
/// `None` if it's from the internal function `Vnode`.
vnode_count: Option<usize>,

/// A list of expressions to get the distribution key columns. Typically `InputRef`.
Expand Down Expand Up @@ -55,8 +57,12 @@ fn build_user(_: DataType, children: Vec<BoxedExpression>) -> Result<BoxedExpres
.eval_const() // required to be constant
.ok()
.flatten() // required to be non-null
.context("rw_vnode expects the first argument to be a non-null constant")?
.context("the first argument (vnode count) must be a non-null constant")?
.into_int16() as usize;
if vnode_count == 0 {
return Err(anyhow::anyhow!("the first argument (vnode count) must not be zero").into());
}

let children = children.collect_vec();

Ok(Box::new(VnodeExpression {
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/expr/type_inference/func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ fn infer_type_for_special(
}
ExprType::VnodeUser => {
ensure_arity!("vnode", 2 <= | inputs |);
inputs[0].cast_implicit_mut(DataType::Int16)?;
inputs[0].cast_explicit_mut(DataType::Int16)?;
Ok(Some(VirtualNode::RW_TYPE))
}
ExprType::Greatest | ExprType::Least => {
Expand Down

0 comments on commit 67df70e

Please sign in to comment.