8000 Loss of precision and wrong rounding (PostgreSQL incompatible) in float to decimal conversion · Issue #16563 · duckdb/duckdb · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Loss of precision and wrong rounding (PostgreSQL incompatible) in float to decimal conversion #16563
Closed
@soerenwolfers

Description

@soerenwolfers

What happens?

(This is part 1/3 of breaking down #14779 into independent and suriviving problems)

select 200_000_000_000_000::float8::decimal(38, 9), 1.45::float8::decimal(3, 1);

returns

┌────────────────────────────────────────────────────────┬────────────────────────────────────────────┐
│ CAST(CAST(200000000000000 AS DOUBLE) AS DECIMAL(38,9)) ┆ CAST(CAST(1.45 AS DOUBLE) AS DECIMAL(3,1)) │
╞════════════════════════════════════════════════════════╪════════════════════════════════════════════╡
│                              199999999999999.983222784 ┆                                        1.4 │
└────────────────────────────────────────────────────────┴────────────────────────────────────────────┘

but should return 200000000000000.000000000, 1.5, like PostgreSQL does.

To Reproduce

DuckDB: https://shell.duckdb.org/#queries=v0,select-200_000_000_000_000%3A%3Afloat8%3A%3Adecimal(38%2C-9)%2C-1.45%3A%3Afloat8%3A%3Adecimal(3%2C-1)~
PG: https://www.db-fiddle.com/f/xzn39x6udTmfKKn9KpuiFz/4

OS:

.

DuckDB Version:

'1.2.2-dev15'

DuckDB Client:

.

Hardware:

.

Full Name:

Soeren Wolfers

Affiliation:

G-Research

What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.

I have tested with a nightly build

Did you include all relevant data sets for reproducing the issue?

Not applicable - the reproduction does not require a data set

Did you include all code required to reproduce the issue?

  • Yes, I have

Did you include all relevant configuration (e.g., CPU architecture, Python version, Linux distribution) to reproduce the issue?

  • Yes, I have

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0