Skip to content

ceil, floor on decimal can produce spurious overflow #22511

@neilconway

Description

@neilconway

Describe the bug

ceil and floor on decimal inputs can raise a spurious overflow because it reuses the input value's scale and precision.

To Reproduce

> select ceil(CAST(9.9 AS DECIMAL(2,1)));
Arrow error: Compute error: Decimal overflow while applying ceil
> SELECT floor(CAST(-9.9 AS DECIMAL(2,1)));
Arrow error: Compute error: Decimal overflow while applying floor

Expected behavior

The queries should return 10 and -10, respectively, which is what Postgres and DuckDB both do.

Additional context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions