Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INSERT INTO VALUES does not allow full range of decimal values equal to zero #5282

Closed
MichaelDrogalis opened this issue May 5, 2020 · 2 comments
Assignees
Milestone

Comments

@MichaelDrogalis
Copy link
Contributor

Describe the bug

The statement INSERT INTO VALUES doesn't seem to work with valid decimal input.

To Reproduce

ksqlDB 0.8.1:

Create a stream:

CREATE STREAM s1 (
    x DECIMAL(12, 2)
) WITH (
    kafka_topic = 's1',
    partitions = 1,
    value_format='avro'
);

This works:

INSERT INTO s1 (x) VALUES (0);

But none of these do:

ksql> INSERT INTO s1 (x) VALUES (0.00);
Failed to insert values into 'S1'. Code generation failed for insert value: DECIMAL precision must be >= scale: DECIMAL(1,2). expression:0.00, schema:`ROWKEY` STRING KEY, `X` DECIMAL(12, 2)
ksql> INSERT INTO s1 (x) VALUES (0.0);
Failed to insert values into 'S1'. Could not serialize row: [ 0.0 ]

Expected behavior

All of the inserts should work.

@MichaelDrogalis MichaelDrogalis added this to the 0.10.0 milestone May 5, 2020
@nae701 nae701 self-assigned this May 29, 2020
@nae701 nae701 changed the title INSERT INTO VALUES does not allow full range of decimal values INSERT INTO VALUES does not allow full range of decimal values starting with zero Jun 1, 2020
@nae701 nae701 changed the title INSERT INTO VALUES does not allow full range of decimal values starting with zero INSERT INTO VALUES does not allow full range of decimal values equal to zero Jun 1, 2020
@nae701
Copy link
Contributor

nae701 commented Jun 1, 2020

Almog found this answer on stackoverflow that explains that BigDecimal in java "the special case that the number is equal to zero (i.e. 0.000), the precision is always 1." and was the source of this bug
https://stackoverflow.com/questions/35435691/bigdecimal-precision-and-scale/35436935#35436935

@apurvam
Copy link
Contributor

apurvam commented Jul 14, 2020

It looks like this has been fixed by the linked PRs. Closing this out.

@apurvam apurvam closed this as completed Jul 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants