Skip to content

Commit

Permalink
fix comment
Browse files Browse the repository at this point in the history
  • Loading branch information
leiysky committed May 13, 2022
1 parent 68a65f1 commit 0152652
Showing 1 changed file with 32 additions and 26 deletions.
58 changes: 32 additions & 26 deletions query/src/sql/planner/semantic/type_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl<'a> TypeChecker<'a> {
left: Box::new(ge_func),
right: Box::new(le_func),
}
.into(),
.into(),
BooleanType::new_impl(),
))
} else {
Expand All @@ -166,7 +166,7 @@ impl<'a> TypeChecker<'a> {
left: Box::new(lt_func),
right: Box::new(gt_func),
}
.into(),
.into(),
BooleanType::new_impl(),
))
}
Expand Down Expand Up @@ -195,7 +195,7 @@ impl<'a> TypeChecker<'a> {
from_type: data_type,
target_type: cast_func.return_type(),
}
.into(),
.into(),
cast_func.return_type(),
))
}
Expand Down Expand Up @@ -229,7 +229,7 @@ impl<'a> TypeChecker<'a> {
value,
data_type: data_type.clone(),
}
.into(),
.into(),
data_type,
))
}
Expand Down Expand Up @@ -293,7 +293,7 @@ impl<'a> TypeChecker<'a> {
},
return_type: agg_func.return_type()?,
}
.into(),
.into(),
agg_func.return_type()?,
))
} else {
Expand All @@ -313,7 +313,7 @@ impl<'a> TypeChecker<'a> {
args: vec![],
return_type: agg_func.return_type()?,
}
.into(),
.into(),
agg_func.return_type()?,
))
}
Expand All @@ -335,7 +335,7 @@ impl<'a> TypeChecker<'a> {
from_type: data_type,
target_type: cast_func.return_type(),
}
.into(),
.into(),
cast_func.return_type(),
))
}
Expand Down Expand Up @@ -377,7 +377,7 @@ impl<'a> TypeChecker<'a> {
arg_types: arg_types.to_vec(),
return_type: func.return_type(),
}
.into(),
.into(),
func.return_type(),
))
}
Expand Down Expand Up @@ -429,7 +429,7 @@ impl<'a> TypeChecker<'a> {
left: Box::new(left),
right: Box::new(right),
}
.into(),
.into(),
BooleanType::new_impl(),
))
}
Expand All @@ -442,7 +442,7 @@ impl<'a> TypeChecker<'a> {
left: Box::new(left),
right: Box::new(right),
}
.into(),
.into(),
BooleanType::new_impl(),
))
}
Expand All @@ -455,7 +455,7 @@ impl<'a> TypeChecker<'a> {
left: Box::new(left),
right: Box::new(right),
}
.into(),
.into(),
BooleanType::new_impl(),
))
}
Expand All @@ -469,17 +469,22 @@ impl<'a> TypeChecker<'a> {
child: &Expr<'a>,
required_type: Option<DataTypeImpl>,
) -> Result<(Scalar, DataTypeImpl)> {
if *op == UnaryOperator::Plus {
// Omit unary + operator
return self.resolve(child, required_type).await;
}
let op_name = match op {
UnaryOperator::Minus => "negate".to_string(),
_ => op.to_string(),
};
match op {
UnaryOperator::Plus => {
// Omit unary + operator
self.resolve(child, required_type).await
}

UnaryOperator::Minus => {
self.resolve_function("negate", &[child], required_type)
.await
}

self.resolve_function(op_name.as_str(), &[child], required_type)
.await
_ => {
self.resolve_function(op.to_string().as_str(), &[child], required_type)
.await
}
}
}

pub async fn resolve_extract_expr(
Expand Down Expand Up @@ -579,9 +584,8 @@ impl<'a> TypeChecker<'a> {
)))?,
};

let mut data_type = value.data_type();
if let Literal::Interval(interval) = literal {
data_type = match &interval.field {
let data_type = if let Literal::Interval(interval) = literal {
match &interval.field {
DateTimeField::Year => IntervalType::new_impl(IntervalKind::Year),
DateTimeField::Month => IntervalType::new_impl(IntervalKind::Month),
DateTimeField::Day => IntervalType::new_impl(IntervalKind::Day),
Expand All @@ -594,8 +598,10 @@ impl<'a> TypeChecker<'a> {
interval.field
)));
}
};
}
}
} else {
value.data_type()
};

Ok((value, data_type))
}
Expand Down

0 comments on commit 0152652

Please sign in to comment.