Skip to content

DECIMAL field truncates on precision loss, rather than rounds #5288

@jardayn

Description

@jardayn

What happens?

When I insert a DECIMAL or FLOAT of a higher precision than the column supports - PSQL/MySQL rounds it before saving.

DuckDB truncates. Which makes it an outlier.

To test in PSQL:

CREATE TABLE qwe (
	id serial PRIMARY KEY,
	dec decimal(10,3) NOT NULL,
	fl NUMERIC ( 10,3 ) NOT NULL
)

INSERT INTO qwe(dec,fl) VALUES (20.999999,5.99999999),(5.123123,5.123123123),

SELECT * FROM qwe

To Reproduce

CREATE TABLE test(
dec DECIMAL(5,3)
)

INSERT INTO test VALUES (2.99999),(3.123), (8.8976553)

SELECT * FROM test

OS:

linux

DuckDB Version:

5.0.2

DuckDB Client:

Python

Full Name:

Igor

Affiliation:

none.

Have you tried this on the latest master branch?

  • I agree

Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?

  • I agree

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions