Skip to content

SQL parsing allows two arguments for ceil/floor #18175

@Jefffrey

Description

@Jefffrey

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:

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 field fields

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

Labels

bugSomething isn't workinggood first issueGood for newcomers

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions