Skip to content

Commit

Permalink
feat: cast expr_sub into f64
Browse files Browse the repository at this point in the history
  • Loading branch information
ChobobDev committed Nov 5, 2022
1 parent e359866 commit 2098414
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions core/src/executor/aggregate/state.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use {
crate::{
ast::{Aggregate, CountArgExpr},
ast::{Aggregate, CountArgExpr,DataType},
data::{Key, Value},
executor::{context::BlendContext, context::FilterContext, evaluate::evaluate},
result::Result,
Expand Down Expand Up @@ -123,10 +123,11 @@ impl AggrValue {

fn export(self) -> Result<Value> {
let variance = |sum_square: Value, sum: Value, count: i64| {
let sum_expr1 = sum_square.multiply(&Value::I64(count))?;
let count=Value::I64(count as i64);
let sum_expr1 = sum_square.multiply(&count)?;
let sum_expr2 = sum.multiply(&sum)?;
let expr_sub = sum_expr1.subtract(&sum_expr2)?;
let cnt_square = Value::F64(count as f64).multiply(&Value::F64(count as f64))?;
let expr_sub = sum_expr1.cast(&DataType::Float)?.subtract(&sum_expr2)?;
let cnt_square = count.multiply(&count)?;
expr_sub.divide(&cnt_square)
};

Expand Down

0 comments on commit 2098414

Please sign in to comment.