fix: JSON format to set correct scale of decimals #6295
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
It is the responsibility of the format to ensure the data returned matches the required schema. This includes the scale of decimals. The JSON format was not correctly setting the scale of decimals when deserializing. For example, give:
The above creates a stream with a single value column
PRICE
which should have a scale of2
, i.e. two decimal places.If the data in tbe Kafka record's value was to have too small a scale, e.g.
or
Then the deserializer was returning the decimal as provided, i.e.
12
or12.1
. However, this is incorrect as the schema of the column states is has a scale of two. So all values for the column should have the scale set to two, i.e. the above examples should deserialize to12.00
and12.10
. With this change they now do.Testing done
Usual
Reviewer checklist