Skip to content

Commit 18a6be8

Browse files
authored
Merge pull request #7520 from ariesdevil/num_func_v2
fix: fix ceil return type
2 parents 96b0f55 + 6235146 commit 18a6be8

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed

src/query/functions-v2/src/scalars/math.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,11 @@ pub fn register(registry: &mut FunctionRegistry) {
176176
for left in ALL_INTEGER_TYPES {
177177
with_number_mapped_type!(L, match left {
178178
DataType::L => {
179-
registry.register_1_arg::<NumberType<L>, NumberType<f64>, _, _>(
179+
registry.register_1_arg::<NumberType<L>, NumberType<L>, _, _>(
180180
"ceil",
181181
FunctionProperty::default(),
182182
|_| None,
183-
|val| val as f64,
183+
|val| val,
184184
);
185185
}
186186
_ => unreachable!(),

src/query/functions-v2/tests/it/scalars/math.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ fn test_math() {
2929
test_abs(file);
3030
test_sign(file);
3131
test_trigonometric(file);
32+
test_ceil(file);
3233
test_exp(file);
3334
test_round(file);
3435
test_sqrt(file);
@@ -74,6 +75,16 @@ fn test_trigonometric(file: &mut impl Write) {
7475
)]);
7576
}
7677

78+
fn test_ceil(file: &mut impl Write) {
79+
run_ast(file, "ceil(5)", &[]);
80+
run_ast(file, "ceil(5.6)", &[]);
81+
run_ast(file, "ceil(a)", &[(
82+
"a",
83+
DataType::Float64,
84+
Column::from_data(vec![1.23f64, -1.23]),
85+
)]);
86+
}
87+
7788
fn test_exp(file: &mut impl Write) {
7889
run_ast(file, "exp(2)", &[]);
7990
run_ast(file, "exp(-2)", &[]);

src/query/functions-v2/tests/it/scalars/testdata/math.txt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,45 @@ evaluation (internal):
191191
+--------+--------------------------------------------------------------------------+
192192

193193

194+
ast : ceil(5)
195+
raw expr : ceil(5_u8)
196+
checked expr : ceil<UInt8>(5_u8)
197+
optimized expr : 5_u8
198+
output type : UInt8
199+
output domain : Unknown
200+
output : 5
201+
202+
203+
ast : ceil(5.6)
204+
raw expr : ceil(5.6_f64)
205+
checked expr : ceil<Float64>(5.6_f64)
206+
optimized expr : 6.0_f64
207+
output type : Float64
208+
output domain : Unknown
209+
output : 6.0
210+
211+
212+
ast : ceil(a)
213+
raw expr : ceil(ColumnRef(0)::Float64)
214+
checked expr : ceil<Float64>(ColumnRef(0))
215+
evaluation:
216+
+--------+----------------+---------+
217+
| | a | Output |
218+
+--------+----------------+---------+
219+
| Type | Float64 | Float64 |
220+
| Domain | {-1.23..=1.23} | Unknown |
221+
| Row 0 | 1.23 | 2.0 |
222+
| Row 1 | -1.23 | -1.0 |
223+
+--------+----------------+---------+
224+
evaluation (internal):
225+
+--------+------------------------+
226+
| Column | Data |
227+
+--------+------------------------+
228+
| a | Float64([1.23, -1.23]) |
229+
| Output | Float64([2.0, -1.0]) |
230+
+--------+------------------------+
231+
232+
194233
ast : exp(2)
195234
raw expr : exp(2_u8)
196235
checked expr : exp<UInt8>(2_u8)

0 commit comments

Comments
 (0)