Skip to content

Commit

Permalink
Add missing integer/float upcast for lte (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
cswinter authored Jul 24, 2024
1 parent 22d3b33 commit 84d6a9f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/engine/planning/query_plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,27 @@ fn function2_registry() -> HashMap<Func2Type, Vec<Function2>> {
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,
},
],
),
(
Expand Down
1 change: 1 addition & 0 deletions tests/query_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down

0 comments on commit 84d6a9f

Please sign in to comment.