|
|
|
@ -840,15 +840,15 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> { |
|
|
|
|
NumericBinaryOperands::Decimal(v1, v2) => v1.checked_div(v2)?.into(), |
|
|
|
|
}), |
|
|
|
|
PlanExpression::UnaryPlus(e) => match self.eval_expression(e, tuple)? { |
|
|
|
|
EncodedTerm::FloatLiteral(value) => Some((*value).into()), |
|
|
|
|
EncodedTerm::DoubleLiteral(value) => Some((*value).into()), |
|
|
|
|
EncodedTerm::IntegerLiteral(value) => Some((value).into()), |
|
|
|
|
EncodedTerm::DecimalLiteral(value) => Some((value).into()), |
|
|
|
|
EncodedTerm::FloatLiteral(value) => Some(value.into()), |
|
|
|
|
EncodedTerm::DoubleLiteral(value) => Some(value.into()), |
|
|
|
|
EncodedTerm::IntegerLiteral(value) => Some(value.into()), |
|
|
|
|
EncodedTerm::DecimalLiteral(value) => Some(value.into()), |
|
|
|
|
_ => None, |
|
|
|
|
}, |
|
|
|
|
PlanExpression::UnaryMinus(e) => match self.eval_expression(e, tuple)? { |
|
|
|
|
EncodedTerm::FloatLiteral(value) => Some((-*value).into()), |
|
|
|
|
EncodedTerm::DoubleLiteral(value) => Some((-*value).into()), |
|
|
|
|
EncodedTerm::FloatLiteral(value) => Some((-value).into()), |
|
|
|
|
EncodedTerm::DoubleLiteral(value) => Some((-value).into()), |
|
|
|
|
EncodedTerm::IntegerLiteral(value) => Some((-value).into()), |
|
|
|
|
EncodedTerm::DecimalLiteral(value) => Some((-value).into()), |
|
|
|
|
_ => None, |
|
|
|
@ -1362,8 +1362,8 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> { |
|
|
|
|
_ => None, |
|
|
|
|
}, |
|
|
|
|
PlanExpression::DecimalCast(e) => match self.eval_expression(e, tuple)? { |
|
|
|
|
EncodedTerm::FloatLiteral(value) => Some(Decimal::from_f32(*value).into()), |
|
|
|
|
EncodedTerm::DoubleLiteral(value) => Some(Decimal::from_f64(*value).into()), |
|
|
|
|
EncodedTerm::FloatLiteral(value) => Some(Decimal::from_f32(value).into()), |
|
|
|
|
EncodedTerm::DoubleLiteral(value) => Some(Decimal::from_f64(value).into()), |
|
|
|
|
EncodedTerm::IntegerLiteral(value) => Some(Decimal::from(value).into()), |
|
|
|
|
EncodedTerm::DecimalLiteral(value) => Some(value.into()), |
|
|
|
|
EncodedTerm::BooleanLiteral(value) => { |
|
|
|
@ -1411,8 +1411,8 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> { |
|
|
|
|
match term { |
|
|
|
|
EncodedTerm::BooleanLiteral(value) => Some(value), |
|
|
|
|
EncodedTerm::StringLiteral { .. } => Some(term != ENCODED_EMPTY_STRING_LITERAL), |
|
|
|
|
EncodedTerm::FloatLiteral(value) => Some(*value != 0f32), |
|
|
|
|
EncodedTerm::DoubleLiteral(value) => Some(*value != 0f64), |
|
|
|
|
EncodedTerm::FloatLiteral(value) => Some(value != 0f32), |
|
|
|
|
EncodedTerm::DoubleLiteral(value) => Some(value != 0f64), |
|
|
|
|
EncodedTerm::IntegerLiteral(value) => Some(value != 0), |
|
|
|
|
EncodedTerm::DecimalLiteral(value) => Some(value != Decimal::from(0)), |
|
|
|
|
_ => None, |
|
|
|
@ -1651,31 +1651,31 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> { |
|
|
|
|
}, |
|
|
|
|
EncodedTerm::FloatLiteral(a) => match b { |
|
|
|
|
EncodedTerm::FloatLiteral(b) => Some(a == b), |
|
|
|
|
EncodedTerm::DoubleLiteral(b) => Some(a.to_f64()? == *b), |
|
|
|
|
EncodedTerm::IntegerLiteral(b) => Some(*a == b.to_f32()?), |
|
|
|
|
EncodedTerm::DecimalLiteral(b) => Some(*a == b.to_f32()), |
|
|
|
|
EncodedTerm::DoubleLiteral(b) => Some(a.to_f64()? == b), |
|
|
|
|
EncodedTerm::IntegerLiteral(b) => Some(a == b.to_f32()?), |
|
|
|
|
EncodedTerm::DecimalLiteral(b) => Some(a == b.to_f32()), |
|
|
|
|
EncodedTerm::TypedLiteral { .. } => None, |
|
|
|
|
_ => Some(false), |
|
|
|
|
}, |
|
|
|
|
EncodedTerm::DoubleLiteral(a) => match b { |
|
|
|
|
EncodedTerm::FloatLiteral(b) => Some(*a == b.to_f64()?), |
|
|
|
|
EncodedTerm::FloatLiteral(b) => Some(a == b.to_f64()?), |
|
|
|
|
EncodedTerm::DoubleLiteral(b) => Some(a == b), |
|
|
|
|
EncodedTerm::IntegerLiteral(b) => Some(*a == b.to_f64()?), |
|
|
|
|
EncodedTerm::DecimalLiteral(b) => Some(*a == b.to_f64()), |
|
|
|
|
EncodedTerm::IntegerLiteral(b) => Some(a == b.to_f64()?), |
|
|
|
|
EncodedTerm::DecimalLiteral(b) => Some(a == b.to_f64()), |
|
|
|
|
EncodedTerm::TypedLiteral { .. } => None, |
|
|
|
|
_ => Some(false), |
|
|
|
|
}, |
|
|
|
|
EncodedTerm::IntegerLiteral(a) => match b { |
|
|
|
|
EncodedTerm::FloatLiteral(b) => Some(a.to_f32()? == *b), |
|
|
|
|
EncodedTerm::DoubleLiteral(b) => Some(a.to_f64()? == *b), |
|
|
|
|
EncodedTerm::FloatLiteral(b) => Some(a.to_f32()? == b), |
|
|
|
|
EncodedTerm::DoubleLiteral(b) => Some(a.to_f64()? == b), |
|
|
|
|
EncodedTerm::IntegerLiteral(b) => Some(a == b), |
|
|
|
|
EncodedTerm::DecimalLiteral(b) => Some(Decimal::from(a) == b), |
|
|
|
|
EncodedTerm::TypedLiteral { .. } => None, |
|
|
|
|
_ => Some(false), |
|
|
|
|
}, |
|
|
|
|
EncodedTerm::DecimalLiteral(a) => match b { |
|
|
|
|
EncodedTerm::FloatLiteral(b) => Some(a.to_f32() == *b), |
|
|
|
|
EncodedTerm::DoubleLiteral(b) => Some(a.to_f64() == *b), |
|
|
|
|
EncodedTerm::FloatLiteral(b) => Some(a.to_f32() == b), |
|
|
|
|
EncodedTerm::DoubleLiteral(b) => Some(a.to_f64() == b), |
|
|
|
|
EncodedTerm::IntegerLiteral(b) => Some(a == Decimal::from(b)), |
|
|
|
|
EncodedTerm::DecimalLiteral(b) => Some(a == b), |
|
|
|
|
EncodedTerm::TypedLiteral { .. } => None, |
|
|
|
@ -1796,29 +1796,29 @@ impl<'a, S: StoreConnection + 'a> SimpleEvaluator<S> { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
EncodedTerm::FloatLiteral(a) => match b { |
|
|
|
|
EncodedTerm::FloatLiteral(b) => (*a).partial_cmp(&*b), |
|
|
|
|
EncodedTerm::DoubleLiteral(b) => a.to_f64()?.partial_cmp(&*b), |
|
|
|
|
EncodedTerm::IntegerLiteral(b) => (*a).partial_cmp(&b.to_f32()?), |
|
|
|
|
EncodedTerm::DecimalLiteral(b) => (*a).partial_cmp(&b.to_f32()), |
|
|
|
|
EncodedTerm::FloatLiteral(b) => a.partial_cmp(&b), |
|
|
|
|
EncodedTerm::DoubleLiteral(b) => a.to_f64()?.partial_cmp(&b), |
|
|
|
|
EncodedTerm::IntegerLiteral(b) => a.partial_cmp(&b.to_f32()?), |
|
|
|
|
EncodedTerm::DecimalLiteral(b) => a.partial_cmp(&b.to_f32()), |
|
|
|
|
_ => None, |
|
|
|
|
}, |
|
|
|
|
EncodedTerm::DoubleLiteral(a) => match b { |
|
|
|
|
EncodedTerm::FloatLiteral(b) => (*a).partial_cmp(&b.to_f64()?), |
|
|
|
|
EncodedTerm::DoubleLiteral(b) => (*a).partial_cmp(&*b), |
|
|
|
|
EncodedTerm::IntegerLiteral(b) => (*a).partial_cmp(&b.to_f64()?), |
|
|
|
|
EncodedTerm::DecimalLiteral(b) => (*a).partial_cmp(&b.to_f64()), |
|
|
|
|
EncodedTerm::FloatLiteral(b) => a.partial_cmp(&b.to_f64()?), |
|
|
|
|
EncodedTerm::DoubleLiteral(b) => a.partial_cmp(&b), |
|
|
|
|
EncodedTerm::IntegerLiteral(b) => a.partial_cmp(&b.to_f64()?), |
|
|
|
|
EncodedTerm::DecimalLiteral(b) => a.partial_cmp(&b.to_f64()), |
|
|
|
|
_ => None, |
|
|
|
|
}, |
|
|
|
|
EncodedTerm::IntegerLiteral(a) => match b { |
|
|
|
|
EncodedTerm::FloatLiteral(b) => a.to_f32()?.partial_cmp(&*b), |
|
|
|
|
EncodedTerm::DoubleLiteral(b) => a.to_f64()?.partial_cmp(&*b), |
|
|
|
|
EncodedTerm::FloatLiteral(b) => a.to_f32()?.partial_cmp(&b), |
|
|
|
|
EncodedTerm::DoubleLiteral(b) => a.to_f64()?.partial_cmp(&b), |
|
|
|
|
EncodedTerm::IntegerLiteral(b) => a.partial_cmp(&b), |
|
|
|
|
EncodedTerm::DecimalLiteral(b) => Decimal::from(a).partial_cmp(&b), |
|
|
|
|
_ => None, |
|
|
|
|
}, |
|
|
|
|
EncodedTerm::DecimalLiteral(a) => match b { |
|
|
|
|
EncodedTerm::FloatLiteral(b) => a.to_f32().partial_cmp(&*b), |
|
|
|
|
EncodedTerm::DoubleLiteral(b) => a.to_f64().partial_cmp(&*b), |
|
|
|
|
EncodedTerm::FloatLiteral(b) => a.to_f32().partial_cmp(&b), |
|
|
|
|
EncodedTerm::DoubleLiteral(b) => a.to_f64().partial_cmp(&b), |
|
|
|
|
EncodedTerm::IntegerLiteral(b) => a.partial_cmp(&Decimal::from(b)), |
|
|
|
|
EncodedTerm::DecimalLiteral(b) => a.partial_cmp(&b), |
|
|
|
|
_ => None, |
|
|
|
@ -1885,34 +1885,34 @@ impl NumericBinaryOperands { |
|
|
|
|
fn new(a: EncodedTerm, b: EncodedTerm) -> Option<Self> { |
|
|
|
|
match (a, b) { |
|
|
|
|
(EncodedTerm::FloatLiteral(v1), EncodedTerm::FloatLiteral(v2)) => { |
|
|
|
|
Some(NumericBinaryOperands::Float(*v1, v2.to_f32()?)) |
|
|
|
|
Some(NumericBinaryOperands::Float(v1, v2.to_f32()?)) |
|
|
|
|
} |
|
|
|
|
(EncodedTerm::FloatLiteral(v1), EncodedTerm::DoubleLiteral(v2)) => { |
|
|
|
|
Some(NumericBinaryOperands::Double(v1.to_f64()?, *v2)) |
|
|
|
|
Some(NumericBinaryOperands::Double(v1.to_f64()?, v2)) |
|
|
|
|
} |
|
|
|
|
(EncodedTerm::FloatLiteral(v1), EncodedTerm::IntegerLiteral(v2)) => { |
|
|
|
|
Some(NumericBinaryOperands::Float(*v1, v2.to_f32()?)) |
|
|
|
|
Some(NumericBinaryOperands::Float(v1, v2.to_f32()?)) |
|
|
|
|
} |
|
|
|
|
(EncodedTerm::FloatLiteral(v1), EncodedTerm::DecimalLiteral(v2)) => { |
|
|
|
|
Some(NumericBinaryOperands::Float(*v1, v2.to_f32())) |
|
|
|
|
Some(NumericBinaryOperands::Float(v1, v2.to_f32())) |
|
|
|
|
} |
|
|
|
|
(EncodedTerm::DoubleLiteral(v1), EncodedTerm::FloatLiteral(v2)) => { |
|
|
|
|
Some(NumericBinaryOperands::Double(*v1, v2.to_f64()?)) |
|
|
|
|
Some(NumericBinaryOperands::Double(v1, v2.to_f64()?)) |
|
|
|
|
} |
|
|
|
|
(EncodedTerm::DoubleLiteral(v1), EncodedTerm::DoubleLiteral(v2)) => { |
|
|
|
|
Some(NumericBinaryOperands::Double(*v1, *v2)) |
|
|
|
|
Some(NumericBinaryOperands::Double(v1, v2)) |
|
|
|
|
} |
|
|
|
|
(EncodedTerm::DoubleLiteral(v1), EncodedTerm::IntegerLiteral(v2)) => { |
|
|
|
|
Some(NumericBinaryOperands::Double(*v1, v2.to_f64()?)) |
|
|
|
|
Some(NumericBinaryOperands::Double(v1, v2.to_f64()?)) |
|
|
|
|
} |
|
|
|
|
(EncodedTerm::DoubleLiteral(v1), EncodedTerm::DecimalLiteral(v2)) => { |
|
|
|
|
Some(NumericBinaryOperands::Double(*v1, v2.to_f64())) |
|
|
|
|
Some(NumericBinaryOperands::Double(v1, v2.to_f64())) |
|
|
|
|
} |
|
|
|
|
(EncodedTerm::IntegerLiteral(v1), EncodedTerm::FloatLiteral(v2)) => { |
|
|
|
|
Some(NumericBinaryOperands::Float(v1.to_f32()?, *v2)) |
|
|
|
|
Some(NumericBinaryOperands::Float(v1.to_f32()?, v2)) |
|
|
|
|
} |
|
|
|
|
(EncodedTerm::IntegerLiteral(v1), EncodedTerm::DoubleLiteral(v2)) => { |
|
|
|
|
Some(NumericBinaryOperands::Double(v1.to_f64()?, *v2)) |
|
|
|
|
Some(NumericBinaryOperands::Double(v1.to_f64()?, v2)) |
|
|
|
|
} |
|
|
|
|
(EncodedTerm::IntegerLiteral(v1), EncodedTerm::IntegerLiteral(v2)) => { |
|
|
|
|
Some(NumericBinaryOperands::Integer(v1, v2)) |
|
|
|
@ -1921,10 +1921,10 @@ impl NumericBinaryOperands { |
|
|
|
|
Some(NumericBinaryOperands::Decimal(Decimal::from(v1), v2)) |
|
|
|
|
} |
|
|
|
|
(EncodedTerm::DecimalLiteral(v1), EncodedTerm::FloatLiteral(v2)) => { |
|
|
|
|
Some(NumericBinaryOperands::Float(v1.to_f32(), *v2)) |
|
|
|
|
Some(NumericBinaryOperands::Float(v1.to_f32(), v2)) |
|
|
|
|
} |
|
|
|
|
(EncodedTerm::DecimalLiteral(v1), EncodedTerm::DoubleLiteral(v2)) => { |
|
|
|
|
Some(NumericBinaryOperands::Double(v1.to_f64(), *v2)) |
|
|
|
|
Some(NumericBinaryOperands::Double(v1.to_f64(), v2)) |
|
|
|
|
} |
|
|
|
|
(EncodedTerm::DecimalLiteral(v1), EncodedTerm::IntegerLiteral(v2)) => { |
|
|
|
|
Some(NumericBinaryOperands::Decimal(v1, Decimal::from(v2))) |
|
|
|
|