apache / apache/fluss

[Gateway] DECIMAL decoder rejects exponent notation

Open
#4,214 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2.1k
Forks
625
Avg merge
3d 14h
Merged PRs (30d)
97

Description

### Search before asking

- [x] I searched in the [issues](https://github.com/apache/fluss/issues) and found nothing similar.

### Fluss version

main (development)

### Please describe the bug 🐞

FIP-49 defines the JSON input for `DECIMAL(p, s)` as a string or number. However, the Gateway schema-aware row decoder currently accepts only plain decimal notation and rejects exponent notation.

For example, these values are valid and exactly representable as `DECIMAL(5, 2)`:

```json
{"amount": 1e2}
{"amount": "1e2"}
{"amount": 1234e-2}
{"amount": "1.234e1"}
```

They should decode to `100.00` or `12.34`, but currently result in an invalid-argument error.

### Expected behavior

The decoder should accept exponent notation from both JSON numbers and numeric strings when the value can be represented exactly using the declared precision and scale.

Parsing must remain exact and must not pass through `f64`. Values should still be rejected when they:

- exceed the declared precision;
- carry fractional precision that cannot be represented by the declared scale;
- contain malformed or out-of-range exponents.

### Solution

Parse the sign, mantissa, and exponent directly from the original numeric lexeme, then derive the unscaled decimal value with checked arithmetic.

Add regression tests covering:

- quoted and unquoted exponent notation;
- positive and negative exponents;
- explicit signs;
- scale and precision overflow;
- malformed and out-of-range exponents.

### Are you willing to submit a PR?

- [x] I'm willing to submit a PR!

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the Gateway schema-aware row decoder and trace how DECIMAL values are parsed from JSON numbers and strings. Add regression coverage for quoted and unquoted exponent notation, signs, precision and scale overflow, and malformed or out-of-range exponents; done means exact representable values decode while invalid values remain rejected without passing through f64.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.