Fixes math:min in foreign table ()

This commit is contained in:
Emmanuel Keller 2024-05-10 13:42:40 +01:00 committed by GitHub
parent 7776fa476d
commit 8890053176
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 19 additions and 11 deletions
core/src
lib/tests

View file

@ -380,7 +380,7 @@ impl Aggregator {
collections.push("math::min".into());
}
if self.math_sum.is_some() {
collections.push("math::sun".into());
collections.push("math::sum".into());
}
if self.time_max.is_some() {
collections.push("time::max".into());

View file

@ -105,19 +105,19 @@ pub fn any_like(a: &Value, b: &Value) -> Result<Value, Error> {
}
pub fn less_than(a: &Value, b: &Value) -> Result<Value, Error> {
Ok(a.lt(b).into())
Ok((a.is_none_or_null() || b.is_none_or_null() || a.lt(b)).into())
}
pub fn less_than_or_equal(a: &Value, b: &Value) -> Result<Value, Error> {
Ok(a.le(b).into())
Ok((a.is_none_or_null() || b.is_none_or_null() || a.le(b)).into())
}
pub fn more_than(a: &Value, b: &Value) -> Result<Value, Error> {
Ok(a.gt(b).into())
Ok((a.is_none_or_null() || b.is_none_or_null() || a.gt(b)).into())
}
pub fn more_than_or_equal(a: &Value, b: &Value) -> Result<Value, Error> {
Ok(a.ge(b).into())
Ok((a.is_none_or_null() || b.is_none_or_null() || a.ge(b)).into())
}
pub fn contain(a: &Value, b: &Value) -> Result<Value, Error> {

View file

@ -415,10 +415,10 @@ async fn select_multi_aggregate() -> Result<(), Error> {
'math::mean'
],
one: [
'math::sun'
'math::sum'
],
two: [
'math::sun'
'math::sum'
]
},
type: 'Group'
@ -567,10 +567,10 @@ async fn select_multi_aggregate_composed() -> Result<(), Error> {
'first'
],
one: [
'math::sun'
'math::sum'
],
two: [
'math::sun'
'math::sum'
]
},
type: 'Group'

View file

@ -15,7 +15,9 @@ async fn define_foreign_table() -> Result<(), Error> {
count(),
age,
math::sum(age) AS total,
math::mean(score) AS average
math::mean(score) AS average,
math::max(score) AS max,
math::min(score) AS min
FROM person
GROUP BY age
;
@ -43,7 +45,7 @@ async fn define_foreign_table() -> Result<(), Error> {
"{
events: {},
fields: {},
tables: { person_by_age: 'DEFINE TABLE person_by_age TYPE ANY SCHEMALESS AS SELECT count(), age, math::sum(age) AS total, math::mean(score) AS average FROM person GROUP BY age PERMISSIONS NONE' },
tables: { person_by_age: 'DEFINE TABLE person_by_age TYPE ANY SCHEMALESS AS SELECT count(), age, math::sum(age) AS total, math::mean(score) AS average, math::max(score) AS max, math::min(score) AS min FROM person GROUP BY age PERMISSIONS NONE' },
indexes: {},
lives: {},
}",
@ -62,6 +64,8 @@ async fn define_foreign_table() -> Result<(), Error> {
average: 70,
count: 1,
id: person_by_age:[39],
max: 70,
min: 70,
total: 39
}
]",
@ -80,6 +84,8 @@ async fn define_foreign_table() -> Result<(), Error> {
average: 75,
count: 2,
id: person_by_age:[39],
max: 80,
min: 70,
total: 78
}
]",
@ -98,6 +104,8 @@ async fn define_foreign_table() -> Result<(), Error> {
average: 80,
count: 2,
id: person_by_age:[39],
max: 90,
min: 70,
total: 78
}
]",