From 6469b653cde318f08c653050bd071f688a213db0 Mon Sep 17 00:00:00 2001 From: Mees Delzenne Date: Fri, 16 Feb 2024 11:17:22 +0100 Subject: [PATCH] Bugfix: Fix MATH::SQRT_2 not parsing (#3514) --- core/src/syn/v1/builtin.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/src/syn/v1/builtin.rs b/core/src/syn/v1/builtin.rs index b34c6b2a..39fd28cc 100644 --- a/core/src/syn/v1/builtin.rs +++ b/core/src/syn/v1/builtin.rs @@ -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)); + } }