-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers
Description
Describe the bug
Calling ceil/floor via sql allows passing in two arguments which is not intended.
To Reproduce
> select ceil(50.5123, 1);
+------------------------+
| ceil(Float64(50.5123)) |
+------------------------+
| 51.0 |
+------------------------+
1 row(s) fetched.
Elapsed 0.002 seconds.
> select floor(50.5123, 2347819);
+-------------------------+
| floor(Float64(50.5123)) |
+-------------------------+
| 50.0 |
+-------------------------+Expected behavior
These should return a clear error that we expect only one argument.
Additional context
Issue seems to be here:
datafusion/datafusion/sql/src/expr/mod.rs
Lines 497 to 504 in 7c215ed
| SQLExpr::Floor { | |
| expr, | |
| field: _field, | |
| } => self.sql_fn_name_to_expr(*expr, "floor", schema, planner_context), | |
| SQLExpr::Ceil { | |
| expr, | |
| field: _field, | |
| } => self.sql_fn_name_to_expr(*expr, "ceil", schema, planner_context), |
- Specifically the ignored
fieldfields
We should check these fields to make sure we accept only SQL expressions that correspond to ceil(1) and floor(1) (single arguments).
We should also add tests to our sqllogictest suite to capture this expected error (if not already present).
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers