Bugfix: Fix MATH::SQRT_2 not parsing (#3514)

This commit is contained in:
Mees Delzenne 2024-02-16 11:17:22 +01:00 committed by GitHub
parent 485a224bcd
commit 6469b653cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -269,6 +269,7 @@ pub(crate) fn builtin_name(i: &str) -> IResult<&str, BuiltinName<&str>, ParseErr
product => { fn },
round => { fn },
spread => { fn },
SQRT_2 => { const = constant::Constant::MathSqrt2 },
sqrt => { fn },
stddev => { fn },
sum => { fn },
@ -293,7 +294,6 @@ pub(crate) fn builtin_name(i: &str) -> IResult<&str, BuiltinName<&str>, ParseErr
LOG2_10 => { const = constant::Constant::MathLog210 },
LOG2_E => { const = constant::Constant::MathLog2E },
PI => { const = constant::Constant::MathPi },
SQRT_2 => { const = constant::Constant::MathSqrt2 },
TAU => { const = constant::Constant::MathTau },
},
meta => {
@ -548,4 +548,13 @@ mod tests {
let out = res.unwrap().1;
assert_eq!(out, BuiltinName::Constant(Constant::MathPi));
}
#[test]
fn constant_sqrt_2() {
let sql = "math::SqRt_2";
let res = builtin_name(sql);
assert!(res.is_ok());
let out = res.unwrap().1;
assert_eq!(out, BuiltinName::Constant(Constant::MathSqrt2));
}
}