From 9fff8aca6098d96dd40728d126bc1554bc4b21fa Mon Sep 17 00:00:00 2001 From: Clemens Winter Date: Sun, 21 Jul 2024 12:04:46 -0700 Subject: [PATCH] Add missing integer/float upcast for lte --- src/engine/planning/query_plan.rs | 21 +++++++++++++++++++++ tests/query_tests.rs | 1 + 2 files changed, 22 insertions(+) diff --git a/src/engine/planning/query_plan.rs b/src/engine/planning/query_plan.rs index 6bec3816..65d47aba 100644 --- a/src/engine/planning/query_plan.rs +++ b/src/engine/planning/query_plan.rs @@ -912,6 +912,27 @@ fn function2_registry() -> HashMap> { Box::new(|qp, lhs, rhs| qp.less_than_equals(lhs, rhs)), BasicType::String, ), + Function2 { + factory: Box::new(|qp, lhs, rhs| { + // TODO: not strictly correct, casting int to float can lose precision, causing aliased values to compare differently (value might be smaller but compares as equal) + let rhs = int_to_float_cast(qp, rhs).unwrap(); + qp.less_than_equals(lhs, rhs) + }), + type_lhs: BasicType::Float, + type_rhs: BasicType::Integer, + type_out: Type::unencoded(BasicType::Boolean).mutable(), + encoding_invariance: true, + }, + Function2 { + factory: Box::new(|qp, lhs, rhs| { + let lhs = int_to_float_cast(qp, lhs).unwrap(); + qp.less_than_equals(lhs, rhs) + }), + type_lhs: BasicType::Integer, + type_rhs: BasicType::Float, + type_out: Type::unencoded(BasicType::Boolean).mutable(), + encoding_invariance: true, + }, ], ), ( diff --git a/tests/query_tests.rs b/tests/query_tests.rs index d11f0137..6d43a33c 100644 --- a/tests/query_tests.rs +++ b/tests/query_tests.rs @@ -1287,6 +1287,7 @@ fn test_overflow5() { test_query_ec_err("SELECT sum(largenum) FROM default;", QueryError::Overflow); } +// TODO: sometimes flaky, only returning subset of generated data #[test] fn test_gen_table() { use crate::Value::*;